Skip to content

Commit 7c6fa2d

Browse files
chore: change function visibility and variable name
1 parent ba0d4f1 commit 7c6fa2d

File tree

9 files changed

+24
-25
lines changed

9 files changed

+24
-25
lines changed

src/abstract/authorization.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ abstract class Authorization extends Controller {
1414
/** Login Function */
1515
public function login($req, $res) {
1616

17-
/** Username Variable */
17+
/** Username */
1818
$username = false;
1919

20-
/** Password Variable */
20+
/** Password */
2121
$password = false;
2222

2323
// Overide Username and Password Value

src/abstract/controller.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
/** Abstract Controller Functions */
99
abstract class Controller {
1010

11-
/** Entity or Table All Data */
11+
/** Entity All Data */
1212
private $data;
1313

14-
/** Model Class */
14+
/** Model Class Object */
1515
private $model;
1616

17-
/** Abstract Function for Set Model Class */
17+
/** Abstract Function for Set Model Class Object */
1818
abstract protected function setModel();
1919

20-
/** Abstract Function for Set Table Data */
20+
/** Abstract Function for Set Entity All Data */
2121
abstract protected function setData();
2222

2323
public function __construct() {

src/abstract/model.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
/** Abstract Model Functions */
88
abstract class Model {
99

10-
/** Create Repository from Table */
10+
/** Create Repository from Entity */
1111
private $repository;
1212

13-
/** Entity or Table */
14-
private $table;
13+
/** Entity Class String */
14+
private $entity;
1515

16-
/** Abstract Function for Set Table Class */
17-
abstract protected function setTable();
16+
/** Abstract Function for Set Entity Class String */
17+
abstract protected function setEntity();
1818

1919
public function __construct(private EntityManager $entityManager) {
20-
$this->table = $this->setTable();
21-
$this->repository = $entityManager->getRepository($this->table);
20+
$this->entity = $this->setEntity();
21+
$this->repository = $entityManager->getRepository($this->entity);
2222
}
2323

2424
/** Find All Data */
@@ -60,7 +60,7 @@ public function update(array $args, string $id) {
6060

6161
/** Insert Data */
6262
public function insert(array $args) {
63-
$data = new $this->table;
63+
$data = new $this->entity;
6464

6565
foreach ($args as $key => $value)
6666
$data->__set($key, $value);

src/api/category/model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class Model extends AbstractModel {
99

10-
protected function setTable() {
10+
protected function setEntity() {
1111
return Category::class;
1212
}
1313
}

src/api/category/router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use RestJS\Api\Category\Controller;
77

88
class Router {
9-
function __invoke(RouteCollectorProxy $router) {
9+
public function __invoke(RouteCollectorProxy $router) {
1010
$router->get('/', [Controller::class, "findAll"]);
1111
$router->get('/{id:[0-9]+}/', [Controller::class, "findByColumn"]);
1212
$router->get('/{slug:[a-z0-9-]+}/', [Controller::class, "findByColumn"]);

src/api/user/model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class Model extends AbstractModel {
99

10-
protected function setTable() {
10+
protected function setEntity() {
1111
return User::class;
1212
}
1313
}

src/api/user/router.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use RestJS\Middleware\Upload;
88

99
class Router {
10-
function __invoke(RouteCollectorProxy $router) {
10+
public function __invoke(RouteCollectorProxy $router) {
1111
$router->get('/', [Controller::class, "findAll"]);
1212
$router->get('/{id:[0-9]+}/', [Controller::class, "findByColumn"]);
1313
$router->get('/{username:[a-z0-9-]+}/', [Controller::class, "findByColumn"]);

src/middleware/authorization.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
/** Authorization Middleware */
1515
class Authorization implements MiddlewareInterface {
1616

17-
function __construct(private User $user) {}
17+
public function __construct(private User $user) {}
1818

19-
function process(Request $req, RequestHandler $handler): ResponseInterface {
19+
public function process(Request $req, RequestHandler $handler): ResponseInterface {
2020

2121
/** User Access Token */
2222
$token = $_COOKIE['SSID'] ?? str_replace('Bearer ', '', $req->getHeader('Authorization'))[0] ?? $req->getQueryParams()['accessToken'] ?? null;

src/middleware/upload.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/** File Upload Middleware */
1212
class Upload implements MiddlewareInterface {
1313

14-
function process(Request $req, RequestHandler $handler): ResponseInterface {
14+
public function process(Request $req, RequestHandler $handler): ResponseInterface {
1515

1616
/** User Upload File */
1717
$uploadedFile = $req->getUploadedFiles();
@@ -28,9 +28,8 @@ function process(Request $req, RequestHandler $handler): ResponseInterface {
2828
return $handler->handle($req);
2929
}
3030

31-
3231
/** File Upload to Server Function */
33-
function moveUploadedFile(string $directory, string $type, UploadedFileInterface $uploadedFile) {
32+
private function moveUploadedFile(string $directory, string $type, UploadedFileInterface $uploadedFile) {
3433

3534
/** File Extension */
3635
$ext = pathinfo($uploadedFile->getClientFilename(), PATHINFO_EXTENSION);
@@ -42,8 +41,8 @@ function moveUploadedFile(string $directory, string $type, UploadedFileInterface
4241
!is_dir($directory) && mkdir($directory);
4342

4443
// File Upload to Server
45-
$uploadedFile->moveTo($directory . $filename);
44+
$uploadedFile->moveTo("{$directory}{$filename}");
4645

47-
return $directory . $filename;
46+
return "{$directory}{$filename}";
4847
}
4948
}

0 commit comments

Comments
 (0)