Completed
Push — master ( 4736fa...904b4e )
by Aleksandar
47:30 queued 26:53
created
src/Article/src/Service/DiscussionService.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         $articleFilter    = $this->articleFilter->getInputFilter()->setData($data);
54 54
         $discussionFilter = $this->discussionFilter->getInputFilter()->setData($data);
55 55
 
56
-        if(!$articleFilter->isValid() || !$discussionFilter->isValid()) {
56
+        if (!$articleFilter->isValid() || !$discussionFilter->isValid()) {
57 57
             throw new FilterException($articleFilter->getMessages() + $discussionFilter->getMessages());
58 58
         }
59 59
 
@@ -62,16 +62,16 @@  discard block
 block discarded – undo
62 62
 
63 63
         $article = $articleFilter->getValues();
64 64
         $article += [
65
-            'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']),
65
+            'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]),
66 66
             'type'            => ArticleType::DISCUSSION,
67 67
             'article_id'      => $id,
68 68
             'article_uuid'    => $uuId
69 69
         ];
70 70
 
71
-        $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid;
72
-        unset($article['category_id'], $article['admin_user_id']);
71
+        $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid;
72
+        unset($article[ 'category_id' ], $article[ 'admin_user_id' ]);
73 73
 
74
-        $discussion = $discussionFilter->getValues() + ['article_uuid' => $uuId];
74
+        $discussion = $discussionFilter->getValues() + [ 'article_uuid' => $uuId ];
75 75
 
76 76
         $this->articleMapper->insert($article);
77 77
         $this->articleDiscussionsMapper->insert($discussion);
@@ -83,30 +83,30 @@  discard block
 block discarded – undo
83 83
         $articleFilter    = $this->articleFilter->getInputFilter()->setData($data);
84 84
         $discussionFilter = $this->discussionFilter->getInputFilter()->setData($data);
85 85
 
86
-        if(!$articleFilter->isValid() || !$discussionFilter->isValid()) {
86
+        if (!$articleFilter->isValid() || !$discussionFilter->isValid()) {
87 87
             throw new FilterException($articleFilter->getMessages() + $discussionFilter->getMessages());
88 88
         }
89 89
 
90
-        $article    = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid];
90
+        $article    = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ];
91 91
         $discussion = $discussionFilter->getValues();
92 92
 
93
-        $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']);
94
-        $article['category_uuid']   = $this->categoryMapper->get($article['category_id'])->category_uuid;
95
-        unset($article['category_id'], $article['admin_user_id']);
93
+        $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]);
94
+        $article[ 'category_uuid' ]   = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid;
95
+        unset($article[ 'category_id' ], $article[ 'admin_user_id' ]);
96 96
 
97
-        $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]);
98
-        $this->articleDiscussionsMapper->update($discussion, ['article_uuid' => $article['article_uuid']]);
97
+        $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]);
98
+        $this->articleDiscussionsMapper->update($discussion, [ 'article_uuid' => $article[ 'article_uuid' ] ]);
99 99
     }
100 100
 
101 101
     public function deleteArticle($id)
102 102
     {
103 103
         $discussion = $this->articleDiscussionsMapper->get($id);
104 104
 
105
-        if(!$discussion) {
105
+        if (!$discussion) {
106 106
             throw new \Exception('Article not found!');
107 107
         }
108 108
 
109
-        $this->articleDiscussionsMapper->delete(['article_uuid' => $discussion->article_uuid]);
109
+        $this->articleDiscussionsMapper->delete([ 'article_uuid' => $discussion->article_uuid ]);
110 110
         $this->delete($discussion->article_uuid);
111 111
     }
112 112
 }
Please login to merge, or discard this patch.
src/Article/src/Service/PostService.php 1 patch
Spacing   +23 added lines, -23 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 Article\Service;
6 6
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         $articleFilter = $this->articleFilter->getInputFilter()->setData($data);
96 96
         $postFilter    = $this->postFilter->getInputFilter()->setData($data);
97 97
 
98
-        if(!$articleFilter->isValid() || !$postFilter->isValid()) {
98
+        if (!$articleFilter->isValid() || !$postFilter->isValid()) {
99 99
             throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages());
100 100
         }
101 101
 
@@ -104,23 +104,23 @@  discard block
 block discarded – undo
104 104
 
105 105
         $article = $articleFilter->getValues();
106 106
         $article += [
107
-            'admin_user_uuid' => $this->adminUsersMapper->getUuid($article['admin_user_id']),
107
+            'admin_user_uuid' => $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]),
108 108
             'type'            => ArticleType::POST,
109 109
             'article_id'      => $id,
110 110
             'article_uuid'    => $uuId
111 111
         ];
112 112
 
113
-        $article['category_uuid'] = $this->categoryMapper->get($article['category_id'])->category_uuid;
114
-        unset($article['category_id'], $article['admin_user_id']);
113
+        $article[ 'category_uuid' ] = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid;
114
+        unset($article[ 'category_id' ], $article[ 'admin_user_id' ]);
115 115
 
116 116
         $post = $postFilter->getValues() + [
117 117
                 'featured_img' => $this->upload->uploadImage($data, 'featured_img'),
118 118
                 'main_img'     => $this->upload->uploadImage($data, 'main_img'),
119
-                'article_uuid' => $article['article_uuid']
119
+                'article_uuid' => $article[ 'article_uuid' ]
120 120
             ];
121 121
 
122
-        if($post['is_homepage']) {
123
-            $this->articlePostsMapper->update(['is_homepage' => false]);
122
+        if ($post[ 'is_homepage' ]) {
123
+            $this->articlePostsMapper->update([ 'is_homepage' => false ]);
124 124
         }
125 125
 
126 126
         $this->articleMapper->insert($article);
@@ -133,46 +133,46 @@  discard block
 block discarded – undo
133 133
         $articleFilter = $this->articleFilter->getInputFilter()->setData($data);
134 134
         $postFilter    = $this->postFilter->getInputFilter()->setData($data);
135 135
 
136
-        if(!$articleFilter->isValid() || !$postFilter->isValid()) {
136
+        if (!$articleFilter->isValid() || !$postFilter->isValid()) {
137 137
             throw new FilterException($articleFilter->getMessages() + $postFilter->getMessages());
138 138
         }
139 139
 
140
-        $article = $articleFilter->getValues() + ['article_uuid' => $article->article_uuid];
140
+        $article = $articleFilter->getValues() + [ 'article_uuid' => $article->article_uuid ];
141 141
         $post    = $postFilter->getValues() + [
142 142
                 'featured_img' => $this->upload->uploadImage($data, 'featured_img'),
143 143
                 'main_img'     => $this->upload->uploadImage($data, 'main_img')
144 144
             ];
145 145
 
146
-        $article['admin_user_uuid'] = $this->adminUsersMapper->getUuid($article['admin_user_id']);
147
-        $article['category_uuid']   = $this->categoryMapper->get($article['category_id'])->category_uuid;
148
-        unset($article['category_id'], $article['admin_user_id']);
146
+        $article[ 'admin_user_uuid' ] = $this->adminUsersMapper->getUuid($article[ 'admin_user_id' ]);
147
+        $article[ 'category_uuid' ]   = $this->categoryMapper->get($article[ 'category_id' ])->category_uuid;
148
+        unset($article[ 'category_id' ], $article[ 'admin_user_id' ]);
149 149
 
150 150
         // We dont want to force user to re-upload image on edit
151
-        if(!$post['featured_img']) {
152
-            unset($post['featured_img']);
151
+        if (!$post[ 'featured_img' ]) {
152
+            unset($post[ 'featured_img' ]);
153 153
         }
154 154
 
155
-        if(!$post['main_img']) {
156
-            unset($post['main_img']);
155
+        if (!$post[ 'main_img' ]) {
156
+            unset($post[ 'main_img' ]);
157 157
         }
158 158
 
159
-        if($post['is_homepage']) {
160
-            $this->articlePostsMapper->update(['is_homepage' => false]);
159
+        if ($post[ 'is_homepage' ]) {
160
+            $this->articlePostsMapper->update([ 'is_homepage' => false ]);
161 161
         }
162 162
 
163
-        $this->articleMapper->update($article, ['article_uuid' => $article['article_uuid']]);
164
-        $this->articlePostsMapper->update($post, ['article_uuid' => $article['article_uuid']]);
163
+        $this->articleMapper->update($article, [ 'article_uuid' => $article[ 'article_uuid' ] ]);
164
+        $this->articlePostsMapper->update($post, [ 'article_uuid' => $article[ 'article_uuid' ] ]);
165 165
     }
166 166
 
167 167
     public function deleteArticle($id)
168 168
     {
169 169
         $post = $this->articlePostsMapper->get($id);
170 170
 
171
-        if(!$post) {
171
+        if (!$post) {
172 172
             throw new \Exception('Article not found!');
173 173
         }
174 174
 
175
-        $this->articlePostsMapper->delete(['article_uuid' => $post->article_uuid]);
175
+        $this->articlePostsMapper->delete([ 'article_uuid' => $post->article_uuid ]);
176 176
         $this->delete($post->article_uuid);
177 177
     }
178 178
 
Please login to merge, or discard this patch.
src/Newsletter/src/Mapper/NewsletterMapperFactory.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\Mapper;
6 6
 
Please login to merge, or discard this patch.
src/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.
src/Newsletter/src/Web/Action/HandlePostAction.php 1 patch
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.
src/Newsletter/src/Service/NewsletterServiceFactory.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\Service;
6 6
 
Please login to merge, or discard this patch.
src/Newsletter/src/Service/NewsletterService.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@
 block discarded – undo
15 15
 
16 16
     public function registerNew($email)
17 17
     {
18
-        if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
18
+        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
19 19
             throw new \Exception('Email is not valid!', 400);
20 20
         }
21 21
 
22
-        $current = $this->newsletterMapper->select(['email' => $email])->current();
22
+        $current = $this->newsletterMapper->select([ 'email' => $email ])->current();
23 23
 
24
-        if(!$current) {
25
-            return $this->newsletterMapper->insert(['email' => $email]);
24
+        if (!$current) {
25
+            return $this->newsletterMapper->insert([ 'email' => $email ]);
26 26
         }
27 27
     }
28 28
 }
Please login to merge, or discard this patch.
src/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.
data/phinx/migrations/20170523131220_newsletter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@
 block discarded – undo
7 7
 
8 8
     public function change()
9 9
     {
10
-        $this->table('newsletter', ['id' => false])
10
+        $this->table('newsletter', [ 'id' => false ])
11 11
             ->addColumn('email', 'text')
12
-            ->addColumn('created_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
12
+            ->addColumn('created_at', 'timestamp', [ 'default' => 'CURRENT_TIMESTAMP' ])
13 13
             ->create();
14 14
     }
15 15
 }
Please login to merge, or discard this patch.