Completed
Push — master ( d77924...7aa4c6 )
by Aleksandar
25:35
created
src/Web/ConfigProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
                     'article/pagination' => 'templates/partial/pagination.phtml',
14 14
                 ],
15 15
                 'paths' => [
16
-                    'templates' => ['templates'],
17
-                    'web'       => ['templates/web'],
16
+                    'templates' => [ 'templates' ],
17
+                    'web'       => [ 'templates/web' ],
18 18
                 ],
19 19
             ],
20 20
 
Please login to merge, or discard this patch.
src/Web/Action/HomeAction.php 1 patch
Spacing   +2 added lines, -2 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 Web\Action;
6 6
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     public function __invoke(Request $request, Response $response, callable $next = null): HtmlResponse
47 47
     {
48 48
         // Set custom html from view file
49
-        return new HtmlResponse($this->template->render('web::home', ['layout' => 'layout/web']));
49
+        return new HtmlResponse($this->template->render('web::home', [ 'layout' => 'layout/web' ]));
50 50
 
51 51
         //$article = $this->postService->getHomepage();
52 52
         //
Please login to merge, or discard this patch.
src/Web/Action/PostAction.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 Web\Action;
6 6
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         $urlSlug1 = $request->getAttribute('segment_1');
49 49
         $urlSlug2 = $request->getAttribute('segment_2');
50 50
 
51
-        if($urlSlug2) {
51
+        if ($urlSlug2) {
52 52
             $categorySlug = $urlSlug1;
53 53
             $postSlug     = $urlSlug2;
54 54
         }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
         list($previousPost, $nextPost) = $this->postService->fetchNearestArticle($post->published_at);
63 63
 
64
-        if(!$post) {
64
+        if (!$post) {
65 65
             $response = $response->withStatus(404);
66 66
 
67 67
             return $next($request, $response, new \Exception("Post by URL does not exist!", 404));
Please login to merge, or discard this patch.
src/Web/Action/VideosAction.php 1 patch
Spacing   +2 added lines, -2 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 Web\Action;
6 6
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function __invoke(Request $request, Response $response, callable $next = null)
52 52
     {
53 53
         $params = $request->getQueryParams();
54
-        $page   = isset($params['page']) ? $params['page'] : 1;
54
+        $page   = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
55 55
         $videos = $this->videoService->fetchWebArticles($page, 5);
56 56
 
57 57
         return new HtmlResponse($this->template->render('web::videos', [
Please login to merge, or discard this patch.
src/Admin/src/ConfigProvider.php 1 patch
Spacing   +5 added lines, -5 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
 
@@ -30,25 +30,25 @@  discard block
 block discarded – undo
30 30
                     'name'            => 'auth',
31 31
                     'path'            => '/auth/:action',
32 32
                     'middleware'      => Controller\AuthController::class,
33
-                    'allowed_methods' => ['GET', 'POST'],
33
+                    'allowed_methods' => [ 'GET', 'POST' ],
34 34
                 ],
35 35
                 [
36 36
                     'name'            => 'admin',
37 37
                     'path'            => '/admin',
38 38
                     'middleware'      => Action\IndexAction::class,
39
-                    'allowed_methods' => ['GET'],
39
+                    'allowed_methods' => [ 'GET' ],
40 40
                 ],
41 41
                 [
42 42
                     'name'            => 'admin.users',
43 43
                     'path'            => '/admin/users',
44 44
                     'middleware'      => Controller\UserController::class,
45
-                    'allowed_methods' => ['GET']
45
+                    'allowed_methods' => [ 'GET' ]
46 46
                 ],
47 47
                 [
48 48
                     'name'            => 'admin.users.action',
49 49
                     'path'            => '/admin/users/:action/:id',
50 50
                     'middleware'      => Controller\UserController::class,
51
-                    'allowed_methods' => ['GET', 'POST']
51
+                    'allowed_methods' => [ 'GET', 'POST' ]
52 52
                 ],
53 53
             ],
54 54
 
Please login to merge, or discard this patch.
src/Admin/src/Controller/UserController.php 1 patch
Spacing   +12 added lines, -12 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\Controller;
6 6
 
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $user   = $this->session->getStorage()->user;
66 66
         $params = $this->request->getQueryParams();
67
-        $page   = isset($params['page']) ? $params['page'] : 1;
68
-        $limit  = isset($params['limit']) ? $params['limit'] : 15;
67
+        $page   = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
68
+        $limit  = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15;
69 69
 
70 70
         $adminUsers = $this->adminUserService->getPagination($page, $limit, $user->admin_user_id);
71 71
 
72
-        return new HtmlResponse($this->template->render('admin::user/index', ['list' => $adminUsers, 'layout' => 'layout/admin']));
72
+        return new HtmlResponse($this->template->render('admin::user/index', [ 'list' => $adminUsers, 'layout' => 'layout/admin' ]));
73 73
     }
74 74
 
75 75
     /**
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
      *
78 78
      * @return \Psr\Http\Message\ResponseInterface
79 79
      */
80
-    public function edit($errors = []): \Psr\Http\Message\ResponseInterface
80
+    public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface
81 81
     {
82 82
         $id   = $this->request->getAttribute('id');
83 83
         $user = $this->adminUserService->getUser($id);
84 84
 
85
-        if($this->request->getParsedBody()) {
86
-            $user                = (object)($this->request->getParsedBody() + (array)$user);
85
+        if ($this->request->getParsedBody()) {
86
+            $user                = (object) ($this->request->getParsedBody() + (array) $user);
87 87
             $user->admin_user_id = $id;
88 88
         }
89 89
 
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
         try {
100 100
             $userId = $this->request->getAttribute('id');
101 101
             $data   = $this->request->getParsedBody();
102
-            $data   += (new Request())->getFiles()->toArray();
102
+            $data += (new Request())->getFiles()->toArray();
103 103
 
104
-            if($userId) {
104
+            if ($userId) {
105 105
                 $this->adminUserService->updateUser($data, $userId);
106 106
             }
107 107
             else {
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 
111 111
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.users'));
112 112
         }
113
-        catch(FilterException $fe) {
113
+        catch (FilterException $fe) {
114 114
             return $this->edit($fe->getArrayMessages());
115 115
         }
116
-        catch(\Exception $e) {
116
+        catch (\Exception $e) {
117 117
             throw $e;
118 118
         }
119 119
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.users'));
128 128
         }
129
-        catch(\Exception $e) {
129
+        catch (\Exception $e) {
130 130
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.users'));
131 131
         }
132 132
     }
Please login to merge, or discard this patch.
src/Category/src/View/Helper/CategoryHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
      */
34 34
     public function forWeb()
35 35
     {
36
-        if(!$this->categoriesWithPosts) {
36
+        if (!$this->categoriesWithPosts) {
37 37
             $this->categoriesWithPosts = $this->categoryService->getWebCategories();
38 38
         }
39 39
 
Please login to merge, or discard this patch.
src/Category/src/Service/CategoryService.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Category\Service;
5 5
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function getCategoryBySlug($urlSlug)
71 71
     {
72
-        return $this->categoryMapper->select(['slug' => $urlSlug])->current();
72
+        return $this->categoryMapper->select([ 'slug' => $urlSlug ])->current();
73 73
     }
74 74
 
75 75
     /**
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $filter = $this->categoryFilter->getInputFilter()->setData($data);
84 84
 
85
-        if(!$filter->isValid()) {
85
+        if (!$filter->isValid()) {
86 86
             throw new FilterException($filter->getMessages());
87 87
         }
88 88
 
89 89
         $data                  = $filter->getValues();
90
-        $data['category_id']   = Uuid::uuid1()->toString();
91
-        $data['category_uuid'] = (new MysqlUuid($data['category_id']))->toFormat(new Binary);
90
+        $data[ 'category_id' ]   = Uuid::uuid1()->toString();
91
+        $data[ 'category_uuid' ] = (new MysqlUuid($data[ 'category_id' ]))->toFormat(new Binary);
92 92
 
93 93
         $this->categoryMapper->insert($data);
94 94
     }
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function updateCategory($data, $categoryId)
105 105
     {
106
-        if(!$this->getCategory($categoryId)) {
106
+        if (!$this->getCategory($categoryId)) {
107 107
             throw new \Exception('CategoryId dos not exist.');
108 108
         }
109 109
 
110 110
         $filter = $this->categoryFilter->getInputFilter()->setData($data);
111 111
 
112
-        if(!$filter->isValid()) {
112
+        if (!$filter->isValid()) {
113 113
             throw new FilterException($filter->getMessages());
114 114
         }
115 115
 
116 116
         $data = $filter->getValues();
117
-        $this->categoryMapper->update($data, ['category_id' => $categoryId]);
117
+        $this->categoryMapper->update($data, [ 'category_id' => $categoryId ]);
118 118
     }
119 119
 
120 120
     /**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function delete($categoryId)
127 127
     {
128
-        return (bool)$this->categoryMapper->delete(['category_id' => $categoryId]);
128
+        return (bool) $this->categoryMapper->delete([ 'category_id' => $categoryId ]);
129 129
     }
130 130
 
131 131
     /**
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
     {
146 146
         $categories = $this->categoryMapper->getWeb()->toArray();
147 147
 
148
-        foreach($categories as $ctn => $category) {
149
-            $select                    = $this->categoryMapper->getCategoryPostsSelect($category['category_id'], 4);
148
+        foreach ($categories as $ctn => $category) {
149
+            $select                    = $this->categoryMapper->getCategoryPostsSelect($category[ 'category_id' ], 4);
150 150
             $posts                     = $this->categoryMapper->selectWith($select)->toArray();
151
-            $categories[$ctn]['posts'] = $posts;
151
+            $categories[ $ctn ][ 'posts' ] = $posts;
152 152
         }
153 153
 
154 154
         return $categories;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function allWeb()
161 161
     {
162
-        return $this->categoryMapper->getWeb(null, ['name' => 'asc']);
162
+        return $this->categoryMapper->getWeb(null, [ 'name' => 'asc' ]);
163 163
     }
164 164
 
165 165
     /**
Please login to merge, or discard this patch.
src/Core/Service/AdminUserService.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 namespace Core\Service;
5 5
 
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function loginUser($email, $password)
63 63
     {
64
-        if(!$email || !$password) {
64
+        if (!$email || !$password) {
65 65
             throw new \Exception('Both email and password are required.', 400);
66 66
         }
67 67
 
68 68
         $user = $this->adminUsersMapper->getByEmail($email);
69 69
 
70
-        if(!$user) {
70
+        if (!$user) {
71 71
             throw new \Exception('User does not exist.');
72 72
         }
73 73
 
74
-        if(!$this->crypt->verify($password, $user->password)) {
74
+        if (!$this->crypt->verify($password, $user->password)) {
75 75
             throw new \Exception('Password does not match.');
76 76
         }
77 77
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $filter = $this->adminUserFilter->getInputFilter()->setData($data);
119 119
 
120
-        if(!$filter->isValid()) {
120
+        if (!$filter->isValid()) {
121 121
             throw new FilterException($filter->getMessages());
122 122
         }
123 123
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
                 'profile_img' => $this->upload->uploadImage($data, 'profile_img')
127 127
             ];
128 128
 
129
-        unset($data['confirm_password']);
130
-        $data['password']        = $this->crypt->create($data['password']);
131
-        $data['admin_user_id']   = Uuid::uuid1()->toString();
132
-        $data['admin_user_uuid'] = (new MysqlUuid($data['admin_user_id']))->toFormat(new Binary);
129
+        unset($data[ 'confirm_password' ]);
130
+        $data[ 'password' ]        = $this->crypt->create($data[ 'password' ]);
131
+        $data[ 'admin_user_id' ]   = Uuid::uuid1()->toString();
132
+        $data[ 'admin_user_uuid' ] = (new MysqlUuid($data[ 'admin_user_id' ]))->toFormat(new Binary);
133 133
 
134 134
         return $this->adminUsersMapper->insert($data);
135 135
     }
@@ -143,17 +143,17 @@  discard block
 block discarded – undo
143 143
         $filter = $this->adminUserFilter->getInputFilter()->setData($data);
144 144
 
145 145
         // we dont want to force user to enter the password again
146
-        if($data['password'] == '') {
146
+        if ($data[ 'password' ] == '') {
147 147
             $filter->remove('password');
148 148
             $filter->remove('confirm_password');
149 149
         }
150 150
 
151 151
         // if we want to keep same email
152
-        if($user->email == $data['email']) {
152
+        if ($user->email == $data[ 'email' ]) {
153 153
             $filter->remove('email');
154 154
         }
155 155
 
156
-        if(!$filter->isValid()) {
156
+        if (!$filter->isValid()) {
157 157
             throw new FilterException($filter->getMessages());
158 158
         }
159 159
 
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
             ];
164 164
 
165 165
         // We dont want to force user to re-upload image on edit
166
-        if(!$data['face_img']) {
167
-            unset($data['face_img']);
166
+        if (!$data[ 'face_img' ]) {
167
+            unset($data[ 'face_img' ]);
168 168
         }
169 169
 
170
-        if(!$data['profile_img']) {
171
-            unset($data['profile_img']);
170
+        if (!$data[ 'profile_img' ]) {
171
+            unset($data[ 'profile_img' ]);
172 172
         }
173 173
 
174
-        if(isset($data['password'])) {
175
-            unset($data['confirm_password']);
176
-            $data['password'] = $this->crypt->create($data['password']);
174
+        if (isset($data[ 'password' ])) {
175
+            unset($data[ 'confirm_password' ]);
176
+            $data[ 'password' ] = $this->crypt->create($data[ 'password' ]);
177 177
         }
178 178
 
179
-        return $this->adminUsersMapper->update($data, ['admin_user_id' => $userId]);
179
+        return $this->adminUsersMapper->update($data, [ 'admin_user_id' => $userId ]);
180 180
     }
181 181
 
182 182
     /**
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function delete($userId)
189 189
     {
190
-        return (bool)$this->adminUsersMapper->delete(['admin_user_id' => $userId]);
190
+        return (bool) $this->adminUsersMapper->delete([ 'admin_user_id' => $userId ]);
191 191
     }
192 192
 
193 193
     /**
Please login to merge, or discard this patch.