Skip to content

Commit 534c91b

Browse files
fix: duplicate variable name
1 parent 2ba7e40 commit 534c91b

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/Controller/AbstractAuthController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function login($req, $res) {
2828
throw new HttpBadRequestException($req, "Username or password is required.");
2929

3030
/** Check User Entity */
31-
$user = errorHandler($this->model->findBy(['username' => $username]));
31+
$user = errorHandler($this->_model->findBy(['username' => $username]));
3232

3333
if (!$user)
3434
throw new HttpUnauthorizedException($req, 'Invalid user credentials');

src/Controller/AbstractController.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
class AbstractController {
1010

1111
/** Entity All Data */
12-
private $data;
12+
private $_data;
1313

1414
/** Model Class Object */
15-
private $model;
15+
protected $_model;
1616

1717
public function __construct($model, $data) {
18-
$this->data = $data;
19-
$this->model = $model;
18+
$this->_data = $data;
19+
$this->_model = $model;
2020
}
2121

2222
/** Find All Data */
@@ -26,14 +26,14 @@ public function findAll($req, $res) {
2626
$filter = $req->getQueryParams()['filter'] ?? null;
2727

2828
/** Filter Data */
29-
$data = $this->data;
29+
$data = $this->_data;
3030

3131
// Selected Column Fetch All Data
3232
if ($filter):
3333
$data = [];
3434
$filter = explode(",", $filter);
3535

36-
foreach ($this->data as $item)
36+
foreach ($this->_data as $item)
3737
array_push($data, array_intersect_key((array) $item, array_flip($filter)));
3838
endif;
3939

@@ -44,28 +44,28 @@ public function findAll($req, $res) {
4444
public function findByColumn($req, $res, $args) {
4545

4646
foreach ($args as $key => $value)
47-
$data = array_filter($this->data, fn($item) => $item->$key == $args[$key]);
47+
$data = array_filter($this->_data, fn($item) => $item->$key == $args[$key]);
4848

4949
checkNull($data, $req);
5050
return response($req, $res, args: new Response(data: [...$data]));
5151
}
5252

5353
/** Delete Data by Id */
5454
public function delete($req, $res, $args) {
55-
$data = $this->model->delete($args['id']);
55+
$data = $this->_model->delete($args['id']);
5656
checkNull($data, $req);
5757
return response($req, $res, new Response(message: "This item has been successfully removed.", data: $data));
5858
}
5959

6060
/** Insert Data */
6161
public function insert($req, $res, $args) {
62-
$data = $this->model->insert($req->getParsedBody());
62+
$data = $this->_model->insert($req->getParsedBody());
6363
return response($req, $res, new Response(message: "This item has been successfully added.", data: $data));
6464
}
6565

6666
/** Update by Id */
6767
public function update($req, $res, $args) {
68-
$data = $this->model->update($req->getParsedBody(), $args["id"]);
68+
$data = $this->_model->update($req->getParsedBody(), $args["id"]);
6969
checkNull($data, $req);
7070
return response($req, $res, new Response(message: "This item has been successfully updated.", data: $data));
7171
}

src/Middleware/AbstractAuthMiddleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
abstract class AbstractAuthMiddleware implements MiddlewareInterface {
1515

1616
/** User Class Object */
17-
private $user;
17+
private $_user;
1818

1919
public function __construct($user) {
20-
$this->user = $user;
20+
$this->_user = $user;
2121
}
2222

2323
public function process(Request $req, RequestHandler $handler): ResponseInterface {
@@ -40,7 +40,7 @@ public function process(Request $req, RequestHandler $handler): ResponseInterfac
4040
throw new HttpUnauthorizedException($req, "Invalid access token");
4141

4242
/** Check User Entity */
43-
$user = $this->user->findById($decodedToken['id']);
43+
$user = $this->_user->findById($decodedToken['id']);
4444

4545
if (!$user)
4646
throw new HttpUnauthorizedException($req, "Invalid access token");

0 commit comments

Comments
 (0)