Completed
Push — master ( 291cbd...6aab68 )
by Adeniyi
09:08 queued 06:09
created
api/Controllers/EmojiController.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     protected $dataName;
28 28
     protected $auth;
29 29
 
30
-    public function __construct ()
30
+    public function __construct()
31 31
     {
32 32
         $this->dataName = new Emoji();
33 33
         $this->auth = new AuthController();
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @return json
42 42
      */
43
-    public function getAllEmoji (Slim $app)
43
+    public function getAllEmoji(Slim $app)
44 44
     {
45 45
         $app->response->headers->set('Content-Type', 'application/json');
46 46
         try
47 47
         {
48 48
             $data = $this->dataName->getAll()->toJson();
49 49
             $newData = json_decode($data);
50
-            foreach ( $newData as $key ) {
50
+            foreach ($newData as $key) {
51 51
                 $key->keywords = explode(", ", $key->keywords);
52 52
             }
53 53
             return json_encode($newData);
54
-        } catch ( EmptyDatabaseException $e ) {
54
+        } catch (EmptyDatabaseException $e) {
55 55
             $app->halt(204, json_encode(['Message' => 'No content']));
56 56
         }
57 57
     }
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
      *
65 65
      * @return json
66 66
      */
67
-    public function findEmoji ($id, Slim $app)
67
+    public function findEmoji($id, Slim $app)
68 68
     {
69 69
         $app->response->headers->set('Content-Type', 'application/json');
70 70
         try
71 71
         {
72
-            $data =  $this->dataName->where(['id' => $id])->toJson();
72
+            $data = $this->dataName->where(['id' => $id])->toJson();
73 73
             $newData = json_decode($data);
74
-            foreach ( $newData as $key ) {
74
+            foreach ($newData as $key) {
75 75
                 $key->keywords = explode(", ", $key->keywords);
76 76
             }
77 77
             return json_encode($newData);
78
-        } catch ( DataNotFoundException $e ) {
78
+        } catch (DataNotFoundException $e) {
79 79
             $app->halt(404, json_encode(['Message' => 'Not Found']));
80 80
         }
81 81
     }
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
      *
88 88
      * @return json
89 89
      */
90
-    public function insertEmoji (Slim $app)
90
+    public function insertEmoji(Slim $app)
91 91
     {
92 92
         $app->response->headers->set('Content-Type', 'application/json');
93 93
         $tokenData = $app->request->headers->get('Authorization');
94 94
         try
95 95
         {
96
-            if ( ! isset( $tokenData ) )
96
+            if (!isset($tokenData))
97 97
                 throw new ProvideTokenException();
98 98
 
99 99
             $data = $this->auth->authorizationDecode($tokenData);
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
             $this->dataName->created_by = $data->user;
108 108
 
109 109
             $save = $this->dataName->save();
110
-            if ( $save )
110
+            if ($save)
111 111
                 $app->halt(200, json_encode(['Message' => 'Success']));
112
-        } catch ( ExpiredException $e ){
112
+        } catch (ExpiredException $e) {
113 113
             $app->halt(401, json_encode(['Message' => 'Token has expired']));
114
-        } catch ( DataAlreadyExistException $e ){
114
+        } catch (DataAlreadyExistException $e) {
115 115
             $app->halt(202, json_encode(['Message' => 'Not Created']));
116
-        } catch ( InvalidTokenException $e ){
116
+        } catch (InvalidTokenException $e) {
117 117
             $app->halt(405, json_encode(['Message' => 'Invalid Token']));
118
-        } catch ( ProvideTokenException $e ){
118
+        } catch (ProvideTokenException $e) {
119 119
             $app->halt(406, json_encode(['Message' => 'Enter a valid Token']));
120 120
         }
121 121
     }
@@ -128,35 +128,35 @@  discard block
 block discarded – undo
128 128
      *
129 129
      * @return json
130 130
      */
131
-    public function updateEmoji ($id, Slim $app)
131
+    public function updateEmoji($id, Slim $app)
132 132
     {
133 133
         $app->response->headers->set('Content-Type', 'application/json');
134 134
         $tokenData = $app->request->headers->get('Authorization');
135 135
         try
136 136
         {
137
-            if ( ! isset($tokenData) )
137
+            if (!isset($tokenData))
138 138
                 throw new ProvideTokenException();
139 139
 
140 140
             $find = Emoji::find($id);
141 141
             $this->auth->authorizationDecode($tokenData);
142 142
             $fields = $app->request->isPut() ? $app->request->put() : $app->request->patch();
143
-            foreach ( $fields as $key => $value )
143
+            foreach ($fields as $key => $value)
144 144
             {
145 145
                 $find->$key = $value;
146 146
             }
147 147
             $find->date_modified = date('Y-m-d G:i:s');
148 148
             $update = $find->update();
149
-            if( $update )
149
+            if ($update)
150 150
                 $app->halt(200, json_encode(['Message' => 'Emoji Updated Successfully']));
151
-        } catch ( ExpiredException $e ){
151
+        } catch (ExpiredException $e) {
152 152
             $app->halt(401, json_encode(['Message' => 'Token has expired']));
153
-        } catch ( DataAlreadyExistException $e ){
153
+        } catch (DataAlreadyExistException $e) {
154 154
             $app->halt(304, json_encode(['Message' => 'Not Modified']));
155
-        } catch ( DataNotFoundException $e ){
155
+        } catch (DataNotFoundException $e) {
156 156
             $app->halt(304, json_encode(['Message' => 'Invalid Credential supplied']));
157
-        } catch ( InvalidTokenException $e ){
157
+        } catch (InvalidTokenException $e) {
158 158
             $app->halt(405, json_encode(['Message' => 'Invalid Token']));
159
-        } catch ( ProvideTokenException $e ){
159
+        } catch (ProvideTokenException $e) {
160 160
             $app->halt(406, json_encode(['Message' => 'Enter a valid Token']));
161 161
         }
162 162
     }
@@ -169,24 +169,24 @@  discard block
 block discarded – undo
169 169
      *
170 170
      * @return json
171 171
      */
172
-    public function deleteEmoji ($id, Slim $app)
172
+    public function deleteEmoji($id, Slim $app)
173 173
     {
174 174
         $app->response->headers->set('Content-Type', 'application/json');
175 175
         $tokenData = $app->request->headers->get('Authorization');
176 176
         try
177 177
         {
178
-            if ( ! isset($tokenData) )
178
+            if (!isset($tokenData))
179 179
                 throw new ProvideTokenException();
180 180
 
181 181
             $this->auth->authorizationDecode($tokenData);
182 182
             $deleted = $this->dataName->destroy($id);
183
-            if ( $deleted )
183
+            if ($deleted)
184 184
                 $app->halt(200, json_encode(['Message' => 'Emoji Deleted']));
185
-        } catch ( ExpiredException $e ){
185
+        } catch (ExpiredException $e) {
186 186
             $app->halt(401, json_encode(['Message' => 'Token has expired']));
187
-        } catch ( InvalidTokenException $e ){
187
+        } catch (InvalidTokenException $e) {
188 188
             $app->halt(405, json_encode(['Message' => 'Invalid Token']));
189
-        } catch ( ProvideTokenException $e ){
189
+        } catch (ProvideTokenException $e) {
190 190
             $app->halt(406, json_encode(['Message' => 'Enter a valid Token']));
191 191
         }
192 192
     }
Please login to merge, or discard this patch.
api/Controllers/UserController.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return json
38 38
      */
39
-    public function createUser (Slim $app)
39
+    public function createUser(Slim $app)
40 40
     {
41 41
         $username = $app->request->params('username');
42 42
         $this->user->id = NULL;
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $this->user->date_created = date('Y-m-d H:i:s');
46 46
 
47 47
         $save = $this->user->save();
48
-        if( $save )
48
+        if ($save)
49 49
         {
50 50
             $app->halt(201, json_encode(['message' => 'Registration Successful. Please Login to generate your token']));
51 51
         }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @return json
60 60
      */
61
-    public function login (Slim $app)
61
+    public function login(Slim $app)
62 62
     {
63 63
         $app->response->headers->set('Content-Type', 'application/json');
64 64
         $username = $app->request->params('username');
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         try
67 67
         {
68 68
             $login = $this->user->where(['username' => $username, 'password' => md5($password)], 'AND')->toJson();
69
-            if( ! empty ($login) ){
69
+            if (!empty ($login)) {
70 70
                 $output = json_decode($login);
71 71
                 foreach ($output as $key) {
72 72
                     $output = $key->id;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                     'Authorization' => $this->auth->authorizationEncode($username)
77 77
                 ]));
78 78
             }
79
-        } catch ( DataNotFoundException $e) {
79
+        } catch (DataNotFoundException $e) {
80 80
             $app->halt(404, json_encode(['message' => 'Not Found']));
81 81
         }
82 82
     }
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
      *
89 89
      * @return json
90 90
      */
91
-    public function logout (Slim $app)
91
+    public function logout(Slim $app)
92 92
     {
93 93
         $app->response->headers->set('Content-Type', 'application/json');
94 94
         $tokenData = $app->request->headers->get('Authorization');
95 95
         try
96 96
         {
97
-            if ( ! isset( $tokenData ) )
97
+            if (!isset($tokenData))
98 98
                 throw new ProvideTokenException();
99 99
 
100 100
             $checkUser = $this->user->where(['username' => $tokenData->user])->toJson();
101
-            if( ! empty ($checkUser) ){
102
-                $this->auth->authorizationEncode(NULL);#
101
+            if (!empty ($checkUser)) {
102
+                $this->auth->authorizationEncode(NULL); #
103 103
                 $app->halt(200, json_encode(['message' => 'Logged out Successfully']));
104 104
             }
105
-        } catch ( DataNotFoundException $e) {
105
+        } catch (DataNotFoundException $e) {
106 106
             $app->halt(404, json_encode(['message' => 'Not Found']));
107
-        } catch ( InvalidTokenException $e ){
107
+        } catch (InvalidTokenException $e) {
108 108
             $app->halt(405, json_encode(['Message' => 'Invalid Token']));
109
-        } catch ( ProvideTokenException $e ){
109
+        } catch (ProvideTokenException $e) {
110 110
             $app->halt(406, json_encode(['Message' => 'Enter a valid Token']));
111 111
         }
112 112
     }
Please login to merge, or discard this patch.
d.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 block discarded – undo
8 8
 
9 9
 $request = $client->get('/emojis');
10 10
 // $request->setAuth('user', 'pass');
11
-echo $request->getUrl()."<br />";
11
+echo $request->getUrl() . "<br />";
12 12
 // >>> https://api.github.com/user
13 13
 
14 14
 // You must send a request in order for the transfer to occur
15 15
 $response = $request->send();
16 16
 
17
-echo $response->getBody()."<br />";
17
+echo $response->getBody() . "<br />";
18 18
 // >>> {"type":"User", ...
19 19
 
20
-echo $response->getHeader('Content-Length')."<br />";
20
+echo $response->getHeader('Content-Length') . "<br />";
21 21
 // >>> 792
22 22
 
23 23
 $data = $response->json();
Please login to merge, or discard this patch.
test/RoutesTest.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     /**
45 45
      * Test Post endpoint
46 46
      */
47
-   public function testPOSTEmoji()
47
+    public function testPOSTEmoji()
48 48
     {
49 49
         // create our http client (Guzzle)
50 50
         $data = array(
Please login to merge, or discard this patch.