Completed
Pull Request — master (#114)
by
unknown
30:05
created
packages/Admin/src/Middleware/AdminAuth.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
packages/Admin/src/Service/AdminUserService.php 2 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Admin\Service;
6 6
 
@@ -81,17 +81,17 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function loginUser($email, $password)
83 83
     {
84
-        if(!$email || !$password) {
84
+        if (!$email || !$password) {
85 85
             throw new \Exception('Both email and password are required.', 400);
86 86
         }
87 87
 
88 88
         $user = $this->adminUsersMapper->getByEmail($email);
89 89
 
90
-        if(!$user) {
90
+        if (!$user) {
91 91
             throw new \Exception('User does not exist.');
92 92
         }
93 93
 
94
-        if(!$this->crypt->verify($password, $user->password)) {
94
+        if (!$this->crypt->verify($password, $user->password)) {
95 95
             throw new \Exception('Password does not match.');
96 96
         }
97 97
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     {
136 136
         $filter = $this->adminUserFilter->getInputFilter()->setData($data);
137 137
 
138
-        if(!$filter->isValid()) {
138
+        if (!$filter->isValid()) {
139 139
             throw new FilterException($filter->getMessages());
140 140
         }
141 141
 
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
                 'profile_img' => $this->upload->uploadImage($data, 'profile_img')
145 145
             ];
146 146
 
147
-        unset($data['confirm_password']);
148
-        $data['password']        = $this->crypt->create($data['password']);
149
-        $data['admin_user_id']   = Uuid::uuid1()->toString();
150
-        $data['admin_user_uuid'] = (new MysqlUuid($data['admin_user_id']))->toFormat(new Binary);
147
+        unset($data[ 'confirm_password' ]);
148
+        $data[ 'password' ]        = $this->crypt->create($data[ 'password' ]);
149
+        $data[ 'admin_user_id' ]   = Uuid::uuid1()->toString();
150
+        $data[ 'admin_user_uuid' ] = (new MysqlUuid($data[ 'admin_user_id' ]))->toFormat(new Binary);
151 151
 
152 152
         return $this->adminUsersMapper->insert($data);
153 153
     }
@@ -161,17 +161,17 @@  discard block
 block discarded – undo
161 161
         $filter = $this->adminUserFilter->getInputFilter()->setData($data);
162 162
 
163 163
         // we dont want to force user to enter the password again
164
-        if($data['password'] == '') {
164
+        if ($data[ 'password' ] == '') {
165 165
             $filter->remove('password');
166 166
             $filter->remove('confirm_password');
167 167
         }
168 168
 
169 169
         // if we want to keep same email
170
-        if($user->email == $data['email']) {
170
+        if ($user->email == $data[ 'email' ]) {
171 171
             $filter->remove('email');
172 172
         }
173 173
 
174
-        if(!$filter->isValid()) {
174
+        if (!$filter->isValid()) {
175 175
             throw new FilterException($filter->getMessages());
176 176
         }
177 177
 
@@ -181,26 +181,26 @@  discard block
 block discarded – undo
181 181
             ];
182 182
 
183 183
         // We don't want to force user to re-upload image on edit
184
-        if(!$data['face_img']) {
185
-            unset($data['face_img']);
184
+        if (!$data[ 'face_img' ]) {
185
+            unset($data[ 'face_img' ]);
186 186
         }
187
-        else{
187
+        else {
188 188
             $this->upload->deleteFile($user->face_img);
189 189
         }
190 190
 
191
-        if(!$data['profile_img']) {
192
-            unset($data['profile_img']);
191
+        if (!$data[ 'profile_img' ]) {
192
+            unset($data[ 'profile_img' ]);
193 193
         }
194
-        else{
194
+        else {
195 195
             $this->upload->deleteFile($user->profile_img);
196 196
         }
197 197
 
198
-        if(isset($data['password'])) {
199
-            unset($data['confirm_password']);
200
-            $data['password'] = $this->crypt->create($data['password']);
198
+        if (isset($data[ 'password' ])) {
199
+            unset($data[ 'confirm_password' ]);
200
+            $data[ 'password' ] = $this->crypt->create($data[ 'password' ]);
201 201
         }
202 202
 
203
-        return $this->adminUsersMapper->update($data, ['admin_user_id' => $userId]);
203
+        return $this->adminUsersMapper->update($data, [ 'admin_user_id' => $userId ]);
204 204
     }
205 205
 
206 206
     /**
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
      */
213 213
     public function delete($userId)
214 214
     {
215
-        if(!($adminUser = $this->getUser($userId))) {
215
+        if (!($adminUser = $this->getUser($userId))) {
216 216
             throw new \Exception('Admin user not found.');
217 217
         }
218 218
 
219 219
         $this->upload->deleteFile($adminUser->face_img);
220 220
         $this->upload->deleteFile($adminUser->profile_img);
221 221
 
222
-        return (bool)$this->adminUsersMapper->delete(['admin_user_id' => $userId]);
222
+        return (bool) $this->adminUsersMapper->delete([ 'admin_user_id' => $userId ]);
223 223
     }
224 224
 
225 225
     /**
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -167,15 +167,13 @@
 block discarded – undo
167 167
         // We don't want to force user to re-upload image on edit
168 168
         if(!$data['face_img']) {
169 169
             unset($data['face_img']);
170
-        }
171
-        else{
170
+        } else{
172 171
             $this->upload->deleteFile($user->face_img);
173 172
         }
174 173
 
175 174
         if(!$data['profile_img']) {
176 175
             unset($data['profile_img']);
177
-        }
178
-        else{
176
+        } else{
179 177
             $this->upload->deleteFile($user->profile_img);
180 178
         }
181 179
 
Please login to merge, or discard this patch.
packages/Admin/src/ConfigProvider.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                 ],
Please login to merge, or discard this patch.
packages/Admin/src/Filter/AdminUserFilter.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@  discard block
 block discarded – undo
19 19
 
20 20
     public function getInputFilter()
21 21
     {
22
-        if(!$this->inputFilter) {
22
+        if (!$this->inputFilter) {
23 23
             $inputFilter = new InputFilter();
24 24
 
25 25
             $inputFilter->add(
26 26
                 [
27 27
                 'name'       => 'first_name',
28 28
                 'required'   => true,
29
-                'filters'    => [['name' => 'StringTrim']],
29
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
30 30
                 'validators' => [
31
-                    ['name' => 'NotEmpty'],
32
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 255]]
31
+                    [ 'name' => 'NotEmpty' ],
32
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ]
33 33
                 ],
34 34
                 ]
35 35
             );
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
                 [
39 39
                 'name'       => 'last_name',
40 40
                 'required'   => true,
41
-                'filters'    => [['name' => 'StringTrim']],
41
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
42 42
                 'validators' => [
43
-                    ['name' => 'NotEmpty'],
44
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 255]]
43
+                    [ 'name' => 'NotEmpty' ],
44
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 255 ] ]
45 45
                 ],
46 46
                 ]
47 47
             );
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
                 [
51 51
                 'name'       => 'email',
52 52
                 'required'   => true,
53
-                'filters'    => [['name' => 'StringTrim']],
53
+                'filters'    => [ [ 'name' => 'StringTrim' ] ],
54 54
                 'validators' => [
55
-                    ['name' => 'NotEmpty'],
56
-                    ['name' => 'EmailAddress'],
57
-                    ['name' => 'dbnorecordexists', 'options' => ['adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email']],
55
+                    [ 'name' => 'NotEmpty' ],
56
+                    [ 'name' => 'EmailAddress' ],
57
+                    [ 'name' => 'dbnorecordexists', 'options' => [ 'adapter' => $this->adapter, 'table' => 'admin_users', 'field' => 'email' ] ],
58 58
 
59 59
                 ],
60 60
                 ]
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                 [
65 65
                 'name'     => 'introduction',
66 66
                 'required' => false,
67
-                'filters'  => [['name' => 'StringTrim']]
67
+                'filters'  => [ [ 'name' => 'StringTrim' ] ]
68 68
                 ]
69 69
             );
70 70
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 [
73 73
                 'name'     => 'biography',
74 74
                 'required' => false,
75
-                'filters'  => [['name' => 'StringTrim']]
75
+                'filters'  => [ [ 'name' => 'StringTrim' ] ]
76 76
                 ]
77 77
             );
78 78
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
                 'name'       => 'password',
82 82
                 'required'   => true,
83 83
                 'validators' => [
84
-                    ['name' => 'NotEmpty'],
85
-                    ['name' => 'StringLength', 'options' => ['min' => 7, 'max' => 255]]
84
+                    [ 'name' => 'NotEmpty' ],
85
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 7, 'max' => 255 ] ]
86 86
                 ],
87 87
                 ]
88 88
             );
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
                 'name'       => 'confirm_password',
93 93
                 'required'   => true,
94 94
                 'validators' => [
95
-                    ['name' => 'NotEmpty'],
96
-                    ['name' => 'Identical', 'options' => ['token' => 'password']],
95
+                    [ 'name' => 'NotEmpty' ],
96
+                    [ 'name' => 'Identical', 'options' => [ 'token' => 'password' ] ],
97 97
                 ],
98 98
                 ]
99 99
             );
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 [
103 103
                 'name'       => 'status',
104 104
                 'required'   => true,
105
-                'validators' => [['name' => 'NotEmpty'], ['name' => 'Digits']]
105
+                'validators' => [ [ 'name' => 'NotEmpty' ], [ 'name' => 'Digits' ] ]
106 106
                 ]
107 107
             );
108 108
 
Please login to merge, or discard this patch.
packages/Admin/src/Factory/Service/AdminUserServiceFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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(),
Please login to merge, or discard this patch.
packages/Category/tests/View/Helper/CategoryHelperFactoryTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
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')
Please login to merge, or discard this patch.
packages/Category/tests/View/Helper/CategoryHelperTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,26 +16,26 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
packages/Category/tests/Factory/Controller/IndexFactoryTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
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')
Please login to merge, or discard this patch.
packages/Category/tests/Factory/Service/CategoryServiceFactoryTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
     $categoryMapper = $this->getMockBuilder(\Category\Mapper\CategoryMapper::class)
12 12
         ->getMockForAbstractClass();
13 13
     $container = $this->getMockBuilder(\Interop\Container\ContainerInterface::class)
14
-        ->setMethods(['get'])
14
+        ->setMethods([ 'get' ])
15 15
         ->getMockForAbstractClass();
16 16
     $container->expects(static::at(0))
17 17
         ->method('get')
18
-        ->will(static::returnValue(['upload' => ['public_path' => 'test', 'non_public_path' => 'test']]));
18
+        ->will(static::returnValue([ 'upload' => [ 'public_path' => 'test', 'non_public_path' => 'test' ] ]));
19 19
     $container->expects(static::at(1))
20 20
         ->method('get')
21 21
         ->will(static::returnValue($categoryMapper));
Please login to merge, or discard this patch.