@@ -10,33 +10,33 @@ discard block |
||
| 10 | 10 | ->disableOriginalConstructor() |
| 11 | 11 | ->getMockForAbstractClass(); |
| 12 | 12 | $menuHelper = new \Menu\View\Helper\MenuUrlHelper($urlHelper); |
| 13 | - static::assertSame('http://test.example.com', $menuHelper(['href' => 'http://test.example.com'])); |
|
| 13 | + static::assertSame('http://test.example.com', $menuHelper([ 'href' => 'http://test.example.com' ])); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function testInvokingUrlHelperWithPageSlugShouldReturnString() |
| 17 | 17 | { |
| 18 | 18 | $urlHelper = $this->getMockBuilder(\Zend\Expressive\Helper\UrlHelper::class) |
| 19 | - ->setMethods(['__invoke']) |
|
| 19 | + ->setMethods([ '__invoke' ]) |
|
| 20 | 20 | ->disableOriginalConstructor() |
| 21 | 21 | ->getMockForAbstractClass(); |
| 22 | 22 | $urlHelper->expects(static::once()) |
| 23 | 23 | ->method('__invoke') |
| 24 | 24 | ->willReturn('test'); |
| 25 | 25 | $menuHelper = new \Menu\View\Helper\MenuUrlHelper($urlHelper); |
| 26 | - static::assertSame('test', $menuHelper(['page_slug' => 'test-slug', 'href' => false])); |
|
| 26 | + static::assertSame('test', $menuHelper([ 'page_slug' => 'test-slug', 'href' => false ])); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function testInvokingUrlHelperWithCategorySlugShouldReturnString() |
| 30 | 30 | { |
| 31 | 31 | $urlHelper = $this->getMockBuilder(\Zend\Expressive\Helper\UrlHelper::class) |
| 32 | - ->setMethods(['__invoke']) |
|
| 32 | + ->setMethods([ '__invoke' ]) |
|
| 33 | 33 | ->disableOriginalConstructor() |
| 34 | 34 | ->getMockForAbstractClass(); |
| 35 | 35 | $urlHelper->expects(static::once()) |
| 36 | 36 | ->method('__invoke') |
| 37 | 37 | ->willReturn('test'); |
| 38 | 38 | $menuHelper = new \Menu\View\Helper\MenuUrlHelper($urlHelper); |
| 39 | - static::assertSame('test', $menuHelper(['category_slug' => 'test-slug', 'href' => false, 'page_slug' => false])); |
|
| 39 | + static::assertSame('test', $menuHelper([ 'category_slug' => 'test-slug', 'href' => false, 'page_slug' => false ])); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function testInvokingUrlHelperWithAllParamsFalseShouldReturnString() |
@@ -45,6 +45,6 @@ discard block |
||
| 45 | 45 | ->disableOriginalConstructor() |
| 46 | 46 | ->getMockForAbstractClass(); |
| 47 | 47 | $menuHelper = new \Menu\View\Helper\MenuUrlHelper($urlHelper); |
| 48 | - static::assertSame('#', $menuHelper(['category_slug' => false, 'href' => false, 'page_slug' => false])); |
|
| 48 | + static::assertSame('#', $menuHelper([ 'category_slug' => false, 'href' => false, 'page_slug' => false ])); |
|
| 49 | 49 | } |
| 50 | 50 | } |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | /** |
| 13 | 13 | * Fetches a list of ArticleEntity models. |
| 14 | 14 | * |
| 15 | - * @param array $params |
|
| 16 | 15 | * @return \ArrayObject |
| 17 | 16 | */ |
| 18 | 17 | public function fetchAllArticles($page, $limit); |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | namespace Std; |
| 4 | 4 | |
| 5 | 5 | use Psr\Http\Message\ResponseInterface as Response; |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | namespace Std; |
| 4 | 4 | |
| 5 | 5 | class FilterException extends \Exception |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | namespace Admin; |
| 4 | 4 | |
| 5 | 5 | class ConfigProvider |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | 'admin/pagination' => __DIR__ . '/../templates/admin/partial/pagination.phtml', |
| 14 | 14 | ], |
| 15 | 15 | 'paths' => [ |
| 16 | - 'admin' => [__DIR__ . '/../templates/admin'], |
|
| 16 | + 'admin' => [ __DIR__ . '/../templates/admin' ], |
|
| 17 | 17 | ], |
| 18 | 18 | ], |
| 19 | 19 | |
@@ -37,25 +37,25 @@ discard block |
||
| 37 | 37 | 'name' => 'auth', |
| 38 | 38 | 'path' => '/auth/:action', |
| 39 | 39 | 'middleware' => Controller\AuthController::class, |
| 40 | - 'allowed_methods' => ['GET', 'POST'], |
|
| 40 | + 'allowed_methods' => [ 'GET', 'POST' ], |
|
| 41 | 41 | ], |
| 42 | 42 | [ |
| 43 | 43 | 'name' => 'admin', |
| 44 | 44 | 'path' => '/admin', |
| 45 | 45 | 'middleware' => Action\IndexAction::class, |
| 46 | - 'allowed_methods' => ['GET'], |
|
| 46 | + 'allowed_methods' => [ 'GET' ], |
|
| 47 | 47 | ], |
| 48 | 48 | [ |
| 49 | 49 | 'name' => 'admin.users', |
| 50 | 50 | 'path' => '/admin/users', |
| 51 | 51 | 'middleware' => Controller\UserController::class, |
| 52 | - 'allowed_methods' => ['GET'] |
|
| 52 | + 'allowed_methods' => [ 'GET' ] |
|
| 53 | 53 | ], |
| 54 | 54 | [ |
| 55 | 55 | 'name' => 'admin.users.action', |
| 56 | 56 | 'path' => '/admin/users/:action/:id', |
| 57 | 57 | 'middleware' => Controller\UserController::class, |
| 58 | - 'allowed_methods' => ['GET', 'POST'] |
|
| 58 | + 'allowed_methods' => [ 'GET', 'POST' ] |
|
| 59 | 59 | ], |
| 60 | 60 | ], |
| 61 | 61 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | 'middleware_pipeline' => [ |
| 70 | 70 | // execute this middleware on every /admin[*] path |
| 71 | 71 | 'permission' => [ |
| 72 | - 'middleware' => [Middleware\AdminAuth::class], |
|
| 72 | + 'middleware' => [ Middleware\AdminAuth::class ], |
|
| 73 | 73 | 'priority' => 100, |
| 74 | 74 | 'path' => '/admin' |
| 75 | 75 | ], |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function get($id) |
| 34 | 34 | { |
| 35 | - return $this->select(['admin_user_id' => $id])->current(); |
|
| 35 | + return $this->select([ 'admin_user_id' => $id ])->current(); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function getByEmail(string $email) |
| 45 | 45 | { |
| 46 | - return $this->select(['email' => $email])->current(); |
|
| 46 | + return $this->select([ 'email' => $email ])->current(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -54,12 +54,12 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function updateLogin(string $userId): int |
| 56 | 56 | { |
| 57 | - return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
|
| 57 | + return $this->update([ 'last_login' => date('Y-m-d H:i:s') ], [ 'admin_user_id' => $userId ]); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public function getPaginationSelect($userId) |
| 61 | 61 | { |
| 62 | - $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
|
| 62 | + $select = $this->getSql()->select()->order([ 'created_at' => 'desc' ]); |
|
| 63 | 63 | |
| 64 | 64 | $select->where->notEqualTo('admin_user_id', $userId); |
| 65 | 65 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function getRandom($limit) |
| 70 | 70 | { |
| 71 | 71 | $select = $this->getSql()->select() |
| 72 | - ->where(['status' => 1]) |
|
| 72 | + ->where([ 'status' => 1 ]) |
|
| 73 | 73 | ->order(new Expression('rand()')) |
| 74 | 74 | ->limit($limit); |
| 75 | 75 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | public function getUuid($adminUserId) |
| 80 | 80 | { |
| 81 | - $user = $this->select(['admin_user_id' => $adminUserId])->current(); |
|
| 81 | + $user = $this->select([ 'admin_user_id' => $adminUserId ])->current(); |
|
| 82 | 82 | |
| 83 | 83 | if (!$user) { |
| 84 | 84 | throw new \Exception('Admin user does not exist!', 400); |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $user = $this->session->getStorage()->user; |
| 69 | 69 | $params = $this->request->getQueryParams(); |
| 70 | - $page = isset($params['page']) ? $params['page'] : 1; |
|
| 71 | - $limit = isset($params['limit']) ? $params['limit'] : 15; |
|
| 70 | + $page = isset($params[ 'page' ]) ? $params[ 'page' ] : 1; |
|
| 71 | + $limit = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15; |
|
| 72 | 72 | |
| 73 | 73 | $adminUsers = $this->adminUserService->getPagination($page, $limit, $user->admin_user_id); |
| 74 | 74 | |
| 75 | 75 | return new HtmlResponse($this->template->render( |
| 76 | 76 | 'admin::user/index', |
| 77 | - ['list' => $adminUsers, 'layout' => 'layout/admin']) |
|
| 77 | + [ 'list' => $adminUsers, 'layout' => 'layout/admin' ]) |
|
| 78 | 78 | ); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return \Psr\Http\Message\ResponseInterface |
| 85 | 85 | */ |
| 86 | - public function edit($errors = []): \Psr\Http\Message\ResponseInterface |
|
| 86 | + public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface |
|
| 87 | 87 | { |
| 88 | 88 | $id = $this->request->getAttribute('id'); |
| 89 | 89 | $user = $this->adminUserService->getUser($id); |
| 90 | 90 | |
| 91 | 91 | if ($this->request->getParsedBody()) { |
| 92 | - $user = (object)($this->request->getParsedBody() + (array)$user); |
|
| 92 | + $user = (object) ($this->request->getParsedBody() + (array) $user); |
|
| 93 | 93 | $user->admin_user_id = $id; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin')); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - return new HtmlResponse($this->template->render('admin::login', ['layout' => false, 'error' => $error])); |
|
| 71 | + return new HtmlResponse($this->template->render('admin::login', [ 'layout' => false, 'error' => $error ])); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $data = $this->request->getParsedBody(); |
| 86 | - $email = isset($data['email']) ? $data['email'] : null; |
|
| 87 | - $password = isset($data['password']) ? $data['password'] : null; |
|
| 86 | + $email = isset($data[ 'email' ]) ? $data[ 'email' ] : null; |
|
| 87 | + $password = isset($data[ 'password' ]) ? $data[ 'password' ] : null; |
|
| 88 | 88 | |
| 89 | 89 | try { |
| 90 | 90 | $this->session->getStorage()->user = $this->adminUserService->loginUser($email, $password); |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | 'profile_img' => $this->upload->uploadImage($data, 'profile_img') |
| 135 | 135 | ]; |
| 136 | 136 | |
| 137 | - unset($data['confirm_password']); |
|
| 138 | - $data['password'] = $this->crypt->create($data['password']); |
|
| 139 | - $data['admin_user_id'] = Uuid::uuid1()->toString(); |
|
| 140 | - $data['admin_user_uuid'] = (new MysqlUuid($data['admin_user_id']))->toFormat(new Binary); |
|
| 137 | + unset($data[ 'confirm_password' ]); |
|
| 138 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
| 139 | + $data[ 'admin_user_id' ] = Uuid::uuid1()->toString(); |
|
| 140 | + $data[ 'admin_user_uuid' ] = (new MysqlUuid($data[ 'admin_user_id' ]))->toFormat(new Binary); |
|
| 141 | 141 | |
| 142 | 142 | return $this->adminUsersMapper->insert($data); |
| 143 | 143 | } |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); |
| 152 | 152 | |
| 153 | 153 | // we dont want to force user to enter the password again |
| 154 | - if ($data['password'] == '') { |
|
| 154 | + if ($data[ 'password' ] == '') { |
|
| 155 | 155 | $filter->remove('password'); |
| 156 | 156 | $filter->remove('confirm_password'); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // if we want to keep same email |
| 160 | - if ($user->email == $data['email']) { |
|
| 160 | + if ($user->email == $data[ 'email' ]) { |
|
| 161 | 161 | $filter->remove('email'); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -171,24 +171,24 @@ discard block |
||
| 171 | 171 | ]; |
| 172 | 172 | |
| 173 | 173 | // We don't want to force user to re-upload image on edit |
| 174 | - if (!$data['face_img']) { |
|
| 175 | - unset($data['face_img']); |
|
| 174 | + if (!$data[ 'face_img' ]) { |
|
| 175 | + unset($data[ 'face_img' ]); |
|
| 176 | 176 | } else { |
| 177 | 177 | $this->upload->deleteFile($user->face_img); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if (!$data['profile_img']) { |
|
| 181 | - unset($data['profile_img']); |
|
| 180 | + if (!$data[ 'profile_img' ]) { |
|
| 181 | + unset($data[ 'profile_img' ]); |
|
| 182 | 182 | } else { |
| 183 | 183 | $this->upload->deleteFile($user->profile_img); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if (isset($data['password'])) { |
|
| 187 | - unset($data['confirm_password']); |
|
| 188 | - $data['password'] = $this->crypt->create($data['password']); |
|
| 186 | + if (isset($data[ 'password' ])) { |
|
| 187 | + unset($data[ 'confirm_password' ]); |
|
| 188 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - return $this->adminUsersMapper->update($data, ['admin_user_id' => $userId]); |
|
| 191 | + return $this->adminUsersMapper->update($data, [ 'admin_user_id' => $userId ]); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $this->upload->deleteFile($adminUser->face_img); |
| 208 | 208 | $this->upload->deleteFile($adminUser->profile_img); |
| 209 | 209 | |
| 210 | - return (bool)$this->adminUsersMapper->delete(['admin_user_id' => $userId]); |
|
| 210 | + return (bool) $this->adminUsersMapper->delete([ 'admin_user_id' => $userId ]); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |