Completed
Pull Request — master (#39)
by
unknown
10:27
created
src/Admin/Model/Repository/ArticleRepository.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
     /**
20 20
      * @param array $params
21
-     * @return mixed
21
+     * @return \Zend\Db\ResultSet\ResultSetInterface
22 22
      */
23 23
     public function fetchAllArticles($params = array())
24 24
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 
53 53
     public function deleteArticle(ArticleEntity $article)
54 54
     {
55
-        return $this->articleStorage->delete(['article_uuid' => $article->getArticle_uuid()]);
55
+        return $this->articleStorage->delete([ 'article_uuid' => $article->getArticle_uuid() ]);
56 56
     }
57 57
 
58 58
 }
59 59
\ No newline at end of file
Please login to merge, or discard this patch.
data/phinx/migrations/20161201122146_update_article_table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
10 10
             ->addColumn('body', 'text')
11 11
             ->addColumn('lead', 'text')
12 12
             ->addColumn('status', 'integer')
13
-            ->addColumn('user_uuid', 'binary', ['limit' => 16])
14
-            ->addColumn('created_at', 'datetime', ['default' => 'CURRENT_TIMESTAMP'])
13
+            ->addColumn('user_uuid', 'binary', [ 'limit' => 16 ])
14
+            ->addColumn('created_at', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP' ])
15 15
             ->update();
16 16
     }
17 17
 
Please login to merge, or discard this patch.
config/autoload/routes.global.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             'name'            => 'home',
31 31
             'path'            => '/',
32 32
             'middleware'      => Web\Action\IndexAction::class,
33
-            'allowed_methods' => ['GET'],
33
+            'allowed_methods' => [ 'GET' ],
34 34
         ],
35 35
         [
36 36
             'name'       => 'about',
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
             'name'            => 'api.ping',
47 47
             'path'            => '/api/ping',
48 48
             'middleware'      => Web\Action\PingAction::class,
49
-            'allowed_methods' => ['GET'],
49
+            'allowed_methods' => [ 'GET' ],
50 50
         ],
51 51
         [
52 52
             'name'            => 'auth',
53 53
             'path'            => '/auth/:action',
54 54
             'middleware'      => Admin\Controller\AuthController::class,
55
-            'allowed_methods' => ['GET', 'POST'],
55
+            'allowed_methods' => [ 'GET', 'POST' ],
56 56
         ],
57 57
 
58 58
         // Admin
@@ -60,37 +60,37 @@  discard block
 block discarded – undo
60 60
             'name'            => 'admin',
61 61
             'path'            => '/admin',
62 62
             'middleware'      => Admin\Action\IndexAction::class,
63
-            'allowed_methods' => ['GET'],
63
+            'allowed_methods' => [ 'GET' ],
64 64
         ],
65 65
         [
66 66
             'name'            => 'article',
67 67
             'path'            => '/admin/article/:action',
68 68
             'middleware'      => Admin\Controller\ArticleController::class,
69
-            'allowed_methods' => ['GET', 'POST'],
69
+            'allowed_methods' => [ 'GET', 'POST' ],
70 70
         ],
71 71
         [
72 72
             'name'            => 'admin.users',
73 73
             'path'            => '/admin/users',
74 74
             'middleware'      => Admin\Controller\UserController::class,
75
-            'allowed_methods' => ['GET']
75
+            'allowed_methods' => [ 'GET' ]
76 76
         ],
77 77
         [
78 78
             'name'            => 'admin.users.action',
79 79
             'path'            => '/admin/users/:action/:id',
80 80
             'middleware'      => Admin\Controller\UserController::class,
81
-            'allowed_methods' => ['GET', 'POST']
81
+            'allowed_methods' => [ 'GET', 'POST' ]
82 82
         ],
83 83
         [
84 84
             'name'            => 'admin.tags',
85 85
             'path'            => '/admin/tags',
86 86
             'middleware'      => Admin\Controller\TagController::class,
87
-            'allowed_methods' => ['GET'],
87
+            'allowed_methods' => [ 'GET' ],
88 88
         ],
89 89
         [
90 90
             'name'            => 'admin.posts',
91 91
             'path'            => '/admin/posts',
92 92
             'middleware'      => Admin\Controller\PostController::class,
93
-            'allowed_methods' => ['GET'],
93
+            'allowed_methods' => [ 'GET' ],
94 94
         ],
95 95
     ],
96 96
 ];
Please login to merge, or discard this patch.
src/Core/Service/AdminUserService.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $user = $this->adminUsersMapper->getByEmail($email);
54 54
 
55
-        if(!$user){
55
+        if (!$user) {
56 56
             throw new \Exception('User does not exist.');
57 57
         }
58 58
 
59
-        if(!$this->crypt->verify($password, $user->password)){
59
+        if (!$this->crypt->verify($password, $user->password)) {
60 60
             throw new \Exception('Password does not match.');
61 61
         }
62 62
 
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
     public function save($data, $userId = 0)
113 113
     {
114 114
         //@todo Validate data
115
-        if($data['password'] == ''){
116
-            unset($data['password']);
115
+        if ($data[ 'password' ] == '') {
116
+            unset($data[ 'password' ]);
117 117
         }
118
-        else{
119
-            $data['password'] = $this->crypt->create($data['password']);
118
+        else {
119
+            $data[ 'password' ] = $this->crypt->create($data[ 'password' ]);
120 120
         }
121 121
 
122
-        if($userId){
123
-            $this->adminUsersMapper->update($data, ['admin_user_uuid' => $userId]);
122
+        if ($userId) {
123
+            $this->adminUsersMapper->update($data, [ 'admin_user_uuid' => $userId ]);
124 124
         }
125
-        else{
126
-            $data['admin_user_uuid'] = Uuid::uuid1()->toString();
125
+        else {
126
+            $data[ 'admin_user_uuid' ] = Uuid::uuid1()->toString();
127 127
             $this->adminUsersMapper->insert($data);
128 128
         }
129 129
     }
@@ -136,6 +136,6 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function delete($userId)
138 138
     {
139
-        return (bool)$this->adminUsersMapper->delete(['admin_user_uuid' => $userId]);
139
+        return (bool) $this->adminUsersMapper->delete([ 'admin_user_uuid' => $userId ]);
140 140
     }
141 141
 }
Please login to merge, or discard this patch.
src/Admin/Controller/ArticleController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
             'data' => $this->request->getParsedBody()
60 60
         ];
61 61
 
62
-        if (count($data['data']) > 0) {
62
+        if (count($data[ 'data' ]) > 0) {
63 63
             try {
64 64
                 $article = new \Admin\Model\Entity\ArticleEntity();
65 65
                 //generate uuid
66
-                $data['data']['article_uuid'] = Uuid::uuid1()->toString();
67
-                $this->validator->validate($data['data']);
66
+                $data[ 'data' ][ 'article_uuid' ] = Uuid::uuid1()->toString();
67
+                $this->validator->validate($data[ 'data' ]);
68 68
 
69
-                $article->exchangeArray($data['data']);
69
+                $article->exchangeArray($data[ 'data' ]);
70 70
                 var_dump($this->articleRepo->saveArticle($article));
71 71
                 die();
72 72
                 if ($this->articleRepo->saveArticle($article)) {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
                 // handle validation errors
78 78
             } catch (\Admin\Validator\ValidatorException $e) {
79
-                $data['errors'] = $this->validator->getMessages();
79
+                $data[ 'errors' ] = $this->validator->getMessages();
80 80
 
81 81
                 // handle other errors
82 82
             } catch (\Exception $e) {
Please login to merge, or discard this patch.
src/Admin/Action/ArticlePageAction.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
             'data' => $request->getParsedBody()
58 58
         ];
59 59
 
60
-        if (count($data['data']) > 0) {
60
+        if (count($data[ 'data' ]) > 0) {
61 61
             try {
62 62
                 $article = new \Admin\Model\Entity\ArticleEntity();
63
-                $this->validator->validate($data['data']);
63
+                $this->validator->validate($data[ 'data' ]);
64 64
 
65
-                $article->exchangeArray($data['data']);
65
+                $article->exchangeArray($data[ 'data' ]);
66 66
                 if ($this->articleRepo->saveArticle($article)) {
67 67
                     return $this->indexAction($request, $response);
68 68
                 }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
             // handle validation errors
72 72
             } catch (\Admin\Validator\ValidatorException $e) {
73
-                $data['errors'] = $this->validator->getMessages();
73
+                $data[ 'errors' ] = $this->validator->getMessages();
74 74
 
75 75
             // handle other errors
76 76
             } catch (\Exception $e) {
Please login to merge, or discard this patch.
src/Admin/Model/Entity/ArticleEntity.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,10 +84,10 @@
 block discarded – undo
84 84
      */
85 85
     public function getArrayCopy()
86 86
     {
87
-        $data = [];
87
+        $data = [ ];
88 88
 
89 89
         foreach (get_object_vars($this) as $key => $value) {
90
-            $data[$key] = $value;
90
+            $data[ $key ] = $value;
91 91
         }
92 92
 
93 93
         return $data;
Please login to merge, or discard this patch.
src/Admin/Db/ArticleTableGateway.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     public function fetchOne($params)
45 45
     {
46 46
         $select = $this->getSql()->select();
47
-        $select->where->equalTo('article_uuid', $params['article_uuid']);
47
+        $select->where->equalTo('article_uuid', $params[ 'article_uuid' ]);
48 48
         $select->limit(1);
49 49
 
50 50
         return $this->selectWith($select);
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     public function delete($params)
84 84
     {
85 85
         $delete = $this->getSql()->delete();
86
-        $delete->where->equalTo('article_uuid', $params['article_uuid']);
86
+        $delete->where->equalTo('article_uuid', $params[ 'article_uuid' ]);
87 87
 
88 88
         return $this->deleteWith($delete) > 0;
89 89
     }
Please login to merge, or discard this patch.
src/Admin/Validator/ArticleValidator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@
 block discarded – undo
25 25
         $textValidator->setMin(4);
26 26
 
27 27
         $this->messages = new \Zend\Stdlib\ArrayObject();
28
-        if (!$textValidator->isValid($postData['title'])) {
28
+        if (!$textValidator->isValid($postData[ 'title' ])) {
29 29
             $this->messages->offsetSet('title', array_values($textValidator->getMessages()));
30 30
         }
31 31
 
32
-        if (!$textValidator->isValid($postData['lead'])) {
32
+        if (!$textValidator->isValid($postData[ 'lead' ])) {
33 33
             $this->messages->offsetSet('lead', array_values($textValidator->getMessages()));
34 34
         }
35 35
 
36 36
         //@TODO implement custom validator for article body (html structure) validation
37
-        if (!$textValidator->isValid($postData['body'])) {
37
+        if (!$textValidator->isValid($postData[ 'body' ])) {
38 38
             $this->messages->offsetSet('body', array_values($textValidator->getMessages()));
39 39
         }
40 40
 
Please login to merge, or discard this patch.