Completed
Pull Request — master (#97)
by Aleksandar
46:22 queued 13:15
created
packages/Newsletter/src/Web/Action/HandlePostAction.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@
 block discarded – undo
20 20
     {
21 21
         try {
22 22
             $data  = $request->getParsedBody();
23
-            $email = isset($data['email']) ? $data['email'] : null;
23
+            $email = isset($data[ 'email' ]) ? $data[ 'email' ] : null;
24 24
 
25 25
             $this->newsletterService->registerNew($email);
26 26
 
27
-            return new JsonResponse(['message' => 'Uspešno ste se prijavili.']);
27
+            return new JsonResponse([ 'message' => 'Uspešno ste se prijavili.' ]);
28 28
         }
29
-        catch(\Exception $e) {
30
-            return new JsonResponse(['message' => $e->getMessage()], $e->getCode());
29
+        catch (\Exception $e) {
30
+            return new JsonResponse([ 'message' => $e->getMessage() ], $e->getCode());
31 31
         }
32 32
     }
33 33
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@
 block discarded – undo
25 25
             $this->newsletterService->registerNew($email);
26 26
 
27 27
             return new JsonResponse(['message' => 'Uspešno ste se prijavili.']);
28
-        }
29
-        catch(\Exception $e) {
28
+        } catch(\Exception $e) {
30 29
             return new JsonResponse(['message' => $e->getMessage()], $e->getCode());
31 30
         }
32 31
     }
Please login to merge, or discard this patch.
packages/Newsletter/src/Web/Action/HandlePostActionFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace Newsletter\Web\Action;
6 6
 
Please login to merge, or discard this patch.
packages/Newsletter/src/ConfigProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
         return [
10 10
             'templates' => [
11 11
                 'paths' => [
12
-                    'newsletter' => [__DIR__ . '/../templates/newsletter'],
12
+                    'newsletter' => [ __DIR__ . '/../templates/newsletter' ],
13 13
                 ],
14 14
             ],
15 15
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
                     'name'            => 'newsletter-post',
27 27
                     'path'            => '/newsletter',
28 28
                     'middleware'      => Web\Action\HandlePostAction::class,
29
-                    'allowed_methods' => ['POST'],
29
+                    'allowed_methods' => [ 'POST' ],
30 30
                 ],
31 31
             ],
32 32
         ];
Please login to merge, or discard this patch.
packages/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.
packages/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.
packages/Category/src/Controller/IndexController.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
     public function index() : \Psr\Http\Message\ResponseInterface
48 48
     {
49 49
         $params = $this->request->getQueryParams();
50
-        $page   = isset($params['page']) ? $params['page'] : 1;
51
-        $limit  = isset($params['limit']) ? $params['limit'] : 15;
50
+        $page   = isset($params[ 'page' ]) ? $params[ 'page' ] : 1;
51
+        $limit  = isset($params[ 'limit' ]) ? $params[ 'limit' ] : 15;
52 52
 
53 53
         $categories = $this->categoryService->getPagination($page, $limit);
54 54
 
55
-        return new HtmlResponse($this->template->render('category::index/index', ['list' => $categories, 'layout' => 'layout/admin']));
55
+        return new HtmlResponse($this->template->render('category::index/index', [ 'list' => $categories, 'layout' => 'layout/admin' ]));
56 56
     }
57 57
 
58 58
     /**
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
      *
61 61
      * @return \Psr\Http\Message\ResponseInterface
62 62
      */
63
-    public function edit($errors = []): \Psr\Http\Message\ResponseInterface
63
+    public function edit($errors = [ ]): \Psr\Http\Message\ResponseInterface
64 64
     {
65 65
         $id       = $this->request->getAttribute('id');
66 66
         $category = $this->categoryService->getCategory($id);
67 67
 
68
-        if($this->request->getParsedBody()){
69
-            $category              = (object)($this->request->getParsedBody() + (array)$category);
68
+        if ($this->request->getParsedBody()) {
69
+            $category              = (object) ($this->request->getParsedBody() + (array) $category);
70 70
             $category->category_id = $id;
71 71
         }
72 72
 
@@ -79,36 +79,36 @@  discard block
 block discarded – undo
79 79
 
80 80
     public function save()
81 81
     {
82
-        try{
82
+        try {
83 83
             $id   = $this->request->getAttribute('id');
84 84
             $data = $this->request->getParsedBody();
85 85
 
86
-            if($id){
86
+            if ($id) {
87 87
                 $this->categoryService->updateCategory($data, $id);
88 88
             }
89
-            else{
89
+            else {
90 90
                 $this->categoryService->createCategory($data);
91 91
             }
92 92
 
93 93
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories'));
94 94
         }
95
-        catch(FilterException $fe){
95
+        catch (FilterException $fe) {
96 96
             return $this->edit($fe->getArrayMessages());
97 97
         }
98
-        catch(\Exception $e){
98
+        catch (\Exception $e) {
99 99
             throw $e;
100 100
         }
101 101
     }
102 102
 
103 103
     public function delete()
104 104
     {
105
-        try{
105
+        try {
106 106
             $id = $this->request->getAttribute('id');
107 107
             $this->categoryService->delete($id);
108 108
 
109 109
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories'));
110 110
         }
111
-        catch(\Exception $e){
111
+        catch (\Exception $e) {
112 112
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories'));
113 113
         }
114 114
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -85,17 +85,14 @@  discard block
 block discarded – undo
85 85
 
86 86
             if($id){
87 87
                 $this->categoryService->updateCategory($data, $id);
88
-            }
89
-            else{
88
+            } else{
90 89
                 $this->categoryService->createCategory($data);
91 90
             }
92 91
 
93 92
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories'));
94
-        }
95
-        catch(FilterException $fe){
93
+        } catch(FilterException $fe){
96 94
             return $this->edit($fe->getArrayMessages());
97
-        }
98
-        catch(\Exception $e){
95
+        } catch(\Exception $e){
99 96
             throw $e;
100 97
         }
101 98
     }
@@ -107,8 +104,7 @@  discard block
 block discarded – undo
107 104
             $this->categoryService->delete($id);
108 105
 
109 106
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories'));
110
-        }
111
-        catch(\Exception $e){
107
+        } catch(\Exception $e){
112 108
             return $this->response->withStatus(302)->withHeader('Location', $this->router->generateUri('admin.categories'));
113 109
         }
114 110
     }
Please login to merge, or discard this patch.
packages/Category/src/Filter/CategoryFilter.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,26 +12,26 @@
 block discarded – undo
12 12
 
13 13
     public function getInputFilter()
14 14
     {
15
-        if(!$this->inputFilter) {
15
+        if (!$this->inputFilter) {
16 16
             $inputFilter = new InputFilter();
17 17
 
18 18
             $inputFilter->add([
19 19
                 'name'       => 'name',
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
 
28 28
             $inputFilter->add([
29 29
                 'name'       => 'slug',
30 30
                 'required'   => true,
31
-                'filters'    => [['name' => 'StringTrim', 'options' => ['charlist' => '/']]],
31
+                'filters'    => [ [ 'name' => 'StringTrim', 'options' => [ 'charlist' => '/' ] ] ],
32 32
                 'validators' => [
33
-                    ['name' => 'NotEmpty'],
34
-                    ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]],
33
+                    [ 'name' => 'NotEmpty' ],
34
+                    [ 'name' => 'StringLength', 'options' => [ 'min' => 2, 'max' => 100 ] ],
35 35
                 ],
36 36
             ]);
37 37
 
Please login to merge, or discard this patch.
packages/Category/src/ConfigProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
         return [
10 10
             'templates' => [
11 11
                 'paths' => [
12
-                    'category' => [__DIR__ . '/../templates/category'],
12
+                    'category' => [ __DIR__ . '/../templates/category' ],
13 13
                 ],
14 14
             ],
15 15
 
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
                     'name'            => 'admin.categories',
31 31
                     'path'            => '/admin/categories',
32 32
                     'middleware'      => Controller\IndexController::class,
33
-                    'allowed_methods' => ['GET'],
33
+                    'allowed_methods' => [ 'GET' ],
34 34
                 ],
35 35
                 [
36 36
                     'name'            => 'admin.categories.action',
37 37
                     'path'            => '/admin/categories/:action/:id',
38 38
                     'middleware'      => Controller\IndexController::class,
39
-                    'allowed_methods' => ['GET', 'POST']
39
+                    'allowed_methods' => [ 'GET', 'POST' ]
40 40
                 ],
41 41
             ],
42 42
 
Please login to merge, or discard this patch.
packages/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.