@@ -35,6 +35,6 @@ |
||
| 35 | 35 | |
| 36 | 36 | public function getActivePage($urlSlug) |
| 37 | 37 | { |
| 38 | - return $this->select(['slug' => $urlSlug, 'is_active' => true]); |
|
| 38 | + return $this->select([ 'slug' => $urlSlug, 'is_active' => true ]); |
|
| 39 | 39 | } |
| 40 | 40 | } |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | [ |
| 19 | 19 | 'name' => 'title', |
| 20 | 20 | 'required' => true, |
| 21 | - 'filters' => [['name' => 'StringTrim']], |
|
| 21 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 22 | 22 | 'validators' => [ |
| 23 | - ['name' => 'NotEmpty'], |
|
| 24 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
| 23 | + [ 'name' => 'NotEmpty' ], |
|
| 24 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
| 25 | 25 | ], |
| 26 | 26 | ] |
| 27 | 27 | ); |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | [ |
| 31 | 31 | 'name' => 'slug', |
| 32 | 32 | 'required' => true, |
| 33 | - 'filters' => [['name' => 'StringTrim']], |
|
| 33 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 34 | 34 | 'validators' => [ |
| 35 | - ['name' => 'NotEmpty'], |
|
| 36 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]], |
|
| 35 | + [ 'name' => 'NotEmpty' ], |
|
| 36 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ], |
|
| 37 | 37 | ], |
| 38 | 38 | ] |
| 39 | 39 | ); |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | [ |
| 43 | 43 | 'name' => 'body', |
| 44 | 44 | 'required' => true, |
| 45 | - 'filters' => [['name' => 'StringTrim']], |
|
| 45 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 46 | 46 | 'validators' => [ |
| 47 | - ['name' => 'NotEmpty'], |
|
| 48 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100000]], |
|
| 47 | + [ 'name' => 'NotEmpty' ], |
|
| 48 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100000 ] ], |
|
| 49 | 49 | ], |
| 50 | 50 | ] |
| 51 | 51 | ); |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | [ |
| 55 | 55 | 'name' => 'description', |
| 56 | 56 | 'required' => true, |
| 57 | - 'filters' => [['name' => 'StringTrim']], |
|
| 57 | + 'filters' => [ [ 'name' => 'StringTrim' ] ], |
|
| 58 | 58 | 'validators' => [ |
| 59 | - ['name' => 'NotEmpty'], |
|
| 60 | - ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 50000]], |
|
| 59 | + [ 'name' => 'NotEmpty' ], |
|
| 60 | + [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 50000 ] ], |
|
| 61 | 61 | ], |
| 62 | 62 | ] |
| 63 | 63 | ); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | [ |
| 67 | 67 | 'name' => 'has_layout', |
| 68 | 68 | 'required' => false, |
| 69 | - 'filters' => [['name' => 'Boolean']], |
|
| 69 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
| 70 | 70 | ] |
| 71 | 71 | ); |
| 72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | [ |
| 75 | 75 | 'name' => 'is_homepage', |
| 76 | 76 | 'required' => false, |
| 77 | - 'filters' => [['name' => 'Boolean']], |
|
| 77 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
| 78 | 78 | ] |
| 79 | 79 | ); |
| 80 | 80 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | [ |
| 83 | 83 | 'name' => 'is_active', |
| 84 | 84 | 'required' => false, |
| 85 | - 'filters' => [['name' => 'Boolean']], |
|
| 85 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
| 86 | 86 | ] |
| 87 | 87 | ); |
| 88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | [ |
| 91 | 91 | 'name' => 'is_wysiwyg_editor', |
| 92 | 92 | 'required' => false, |
| 93 | - 'filters' => [['name' => 'Boolean']], |
|
| 93 | + 'filters' => [ [ 'name' => 'Boolean' ] ], |
|
| 94 | 94 | ] |
| 95 | 95 | ); |
| 96 | 96 | |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | public function __invoke(ContainerInterface $container) |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - $config = $container->get('config')['upload']; |
|
| 18 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 17 | + $config = $container->get('config')[ 'upload' ]; |
|
| 18 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 19 | 19 | |
| 20 | 20 | // Create pagination object |
| 21 | 21 | $pageMapper = $container->get(PageMapper::class); |
@@ -31,6 +31,9 @@ discard block |
||
| 31 | 31 | $this->adapter = $adapter; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + /** |
|
| 35 | + * @param string $id |
|
| 36 | + */ |
|
| 34 | 37 | public function get($id) |
| 35 | 38 | { |
| 36 | 39 | return $this->select(['admin_user_id' => $id])->current(); |
@@ -40,7 +43,7 @@ discard block |
||
| 40 | 43 | * Get admin user by email. |
| 41 | 44 | * |
| 42 | 45 | * @param string $email email |
| 43 | - * @return array|\ArrayObject|null |
|
| 46 | + * @return string |
|
| 44 | 47 | */ |
| 45 | 48 | public function getByEmail(string $email) |
| 46 | 49 | { |
@@ -50,7 +53,6 @@ discard block |
||
| 50 | 53 | /** |
| 51 | 54 | * Updates login data. |
| 52 | 55 | * |
| 53 | - * @param string $uuid admin user id |
|
| 54 | 56 | * @return int number of affected rows |
| 55 | 57 | */ |
| 56 | 58 | public function updateLogin(string $userId): int |
@@ -58,6 +60,11 @@ discard block |
||
| 58 | 60 | return $this->update(['last_login' => date('Y-m-d H:i:s')], ['admin_user_id' => $userId]); |
| 59 | 61 | } |
| 60 | 62 | |
| 63 | + /** |
|
| 64 | + * @param string $userId |
|
| 65 | + * |
|
| 66 | + * @return \Zend\Db\Sql\Select |
|
| 67 | + */ |
|
| 61 | 68 | public function getPaginationSelect($userId) |
| 62 | 69 | { |
| 63 | 70 | $select = $this->getSql()->select()->order(['created_at' => 'desc']); |
@@ -67,6 +74,9 @@ discard block |
||
| 67 | 74 | return $select; |
| 68 | 75 | } |
| 69 | 76 | |
| 77 | + /** |
|
| 78 | + * @param integer $limit |
|
| 79 | + */ |
|
| 70 | 80 | public function getRandom($limit) |
| 71 | 81 | { |
| 72 | 82 | $select = $this->getSql()->select() |
@@ -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); |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | if (!$user) { |
| 55 | 55 | return $response->withStatus(302)->withHeader( |
| 56 | 56 | 'Location', |
| 57 | - $this->router->generateUri('auth', ['action' => 'login']) |
|
| 57 | + $this->router->generateUri('auth', [ 'action' => 'login' ]) |
|
| 58 | 58 | ); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Admin\Factory\Service; |
| 6 | 6 | |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function __invoke(ContainerInterface $container): AdminUserService |
| 23 | 23 | { |
| 24 | - $config = $container->get('config')['upload']; |
|
| 25 | - $upload = new Upload($config['public_path'], $config['non_public_path']); |
|
| 24 | + $config = $container->get('config')[ 'upload' ]; |
|
| 25 | + $upload = new Upload($config[ 'public_path' ], $config[ 'non_public_path' ]); |
|
| 26 | 26 | |
| 27 | 27 | return new AdminUserService( |
| 28 | 28 | new Bcrypt(), |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | ->disableOriginalConstructor() |
| 11 | 11 | ->getMockForAbstractClass(); |
| 12 | 12 | $container = $this->getMockBuilder(\Interop\Container\ContainerInterface::class) |
| 13 | - ->setMethods(['get']) |
|
| 13 | + ->setMethods([ 'get' ]) |
|
| 14 | 14 | ->getMockForAbstractClass(); |
| 15 | 15 | $container->expects(static::at(0)) |
| 16 | 16 | ->method('get') |
@@ -16,26 +16,26 @@ |
||
| 16 | 16 | public function testForSelectShouldReturnArray() |
| 17 | 17 | { |
| 18 | 18 | $categoryService = $this->getMockBuilder(\Category\Service\CategoryService::class) |
| 19 | - ->setMethods(['getAll']) |
|
| 19 | + ->setMethods([ 'getAll' ]) |
|
| 20 | 20 | ->disableOriginalConstructor() |
| 21 | 21 | ->getMockForAbstractClass(); |
| 22 | 22 | $categoryService->expects(static::once()) |
| 23 | 23 | ->method('getAll') |
| 24 | - ->willReturn([]); |
|
| 24 | + ->willReturn([ ]); |
|
| 25 | 25 | $categoryHelper = new \Category\View\Helper\CategoryHelper($categoryService); |
| 26 | - static::assertSame([], $categoryHelper->forSelect()); |
|
| 26 | + static::assertSame([ ], $categoryHelper->forSelect()); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function testForHomepageShouldReturnArray() |
| 30 | 30 | { |
| 31 | 31 | $categoryService = $this->getMockBuilder(\Category\Service\CategoryService::class) |
| 32 | - ->setMethods(['getCategoriesWithPosts']) |
|
| 32 | + ->setMethods([ 'getCategoriesWithPosts' ]) |
|
| 33 | 33 | ->disableOriginalConstructor() |
| 34 | 34 | ->getMockForAbstractClass(); |
| 35 | 35 | $categoryService->expects(static::once()) |
| 36 | 36 | ->method('getCategoriesWithPosts') |
| 37 | - ->willReturn([]); |
|
| 37 | + ->willReturn([ ]); |
|
| 38 | 38 | $categoryHelper = new \Category\View\Helper\CategoryHelper($categoryService); |
| 39 | - static::assertSame([], $categoryHelper->forHomepage()); |
|
| 39 | + static::assertSame([ ], $categoryHelper->forHomepage()); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | ->disableOriginalConstructor() |
| 11 | 11 | ->getMockForAbstractClass(); |
| 12 | 12 | $container = $this->getMockBuilder(\Interop\Container\ContainerInterface::class) |
| 13 | - ->setMethods(['get']) |
|
| 13 | + ->setMethods([ 'get' ]) |
|
| 14 | 14 | ->getMockForAbstractClass(); |
| 15 | 15 | $container->expects(static::at(0)) |
| 16 | 16 | ->method('get') |