Completed
Branch master (3fc885)
by Temitope
04:11
created
src/Auth/Oauth.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
      * This method authenticate user and log them in if the supplied
17 17
      * credentials are valid.
18 18
      *
19
-     * @param array $loginParams
20 19
      *
21 20
      * @return json jwt
22 21
      */
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     {
64 64
         $tokenId = base64_encode(mcrypt_create_iv(32));
65 65
         $issuedAt = time();
66
-        $notBefore = $issuedAt + 10;  //Adding 10 seconds
66
+        $notBefore = $issuedAt + 10; //Adding 10 seconds
67 67
         $expire = $notBefore + (float) strtotime('+30 days'); // Adding 30 days expiry date
68 68
         $serverName = $_SERVER['HTTP_HOST']; // Retrieve the server name
69 69
 
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
          * Create the token params as an array
73 73
          */
74 74
         $data = [
75
-            'iat'  => $issuedAt,         // Issued at: time when the token was generated
76
-            'jti'  => $tokenId,          // Json Token Id: an unique identifier for the token
77
-            'iss'  => $serverName,       // Issuer
78
-            'nbf'  => $notBefore,        // Not before
79
-            'exp'  => $expire,           // Expire
80
-            'dat'  => $userData,                    // User Information retrieved from the database
75
+            'iat'  => $issuedAt, // Issued at: time when the token was generated
76
+            'jti'  => $tokenId, // Json Token Id: an unique identifier for the token
77
+            'iss'  => $serverName, // Issuer
78
+            'nbf'  => $notBefore, // Not before
79
+            'exp'  => $expire, // Expire
80
+            'dat'  => $userData, // User Information retrieved from the database
81 81
         ];
82 82
 
83 83
         $loadEnv = DatabaseConnection::loadEnv();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         $secretKey = base64_decode(getenv('secret'));
86 86
 
87 87
         $jwt = JWT::encode(
88
-        $data,      //Data to be encoded in the JWT
88
+        $data, //Data to be encoded in the JWT
89 89
         $secretKey, // The signing key
90 90
         'HS512'     // Algorithm used to sign the token
91 91
         );
Please login to merge, or discard this patch.
src/Controller/EmojiController.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -239,6 +239,7 @@
 block discarded – undo
239 239
 
240 240
     /**
241 241
      * This method authenticate and return user id
242
+     * @param Request $request
242 243
      */
243 244
     public function getCurrentUserId($request)
244 245
     {
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author   Temitope Olotin <[email protected]>
4
- * @license  <https://opensource.org/license/MIT> MIT
5
- */
3
+     * @author   Temitope Olotin <[email protected]>
4
+     * @license  <https://opensource.org/license/MIT> MIT
5
+     */
6 6
 namespace Laztopaz\EmojiRestfulAPI;
7 7
 
8 8
 use \Psr\Http\Message\ServerRequestInterface as Request;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
                 $userInfo = (array) $tokenInfo['dat'];
263 263
 
264
-             return $userInfo['id'];
264
+                return $userInfo['id'];
265 265
 
266 266
             }
267 267
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         foreach ($emojis as $key => &$value) {
232 232
             $value['created_by'] = $value['created_by']['firstname'].' '.$value['created_by']['lastname'];
233 233
             $value['category'] = $value['category']['category_name'];
234
-            $value['keywords'] = array_map(function ($key) { return $key['keyword_name']; }, $value['keywords']);
234
+            $value['keywords'] = array_map(function($key) { return $key['keyword_name']; }, $value['keywords']);
235 235
         }
236 236
 
237 237
         return $emojis;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         $authHeader = $request->getHeader('token');
248 248
 
249 249
         try {
250
-            if (is_array($authHeader) && ! empty($authHeader)) {
250
+            if (is_array($authHeader) && !empty($authHeader)) {
251 251
                 $jwtoken = $authHeader[0];
252 252
 
253 253
                 $secretKey = base64_decode(getenv('secret'));
Please login to merge, or discard this patch.
src/Controller/UserController.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
      *
13 13
      * @param $data
14 14
      *
15
-     * @return int $statuscode
15
+     * @return string|null $statuscode
16 16
      */
17 17
     public function createUser(array $data)
18 18
     {
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author   Temitope Olotin <[email protected]>
4
- * @license  <https://opensource.org/license/MIT> MIT
5
- */
3
+     * @author   Temitope Olotin <[email protected]>
4
+     * @license  <https://opensource.org/license/MIT> MIT
5
+     */
6 6
 namespace Laztopaz\EmojiRestfulAPI;
7 7
 
8 8
 class UserController
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
 
16 16
 $app = new Slim\App([
17 17
     'settings' => [
18
-     'debug'               => true,
19
-     'displayErrorDetails' => true,
18
+        'debug'               => true,
19
+        'displayErrorDetails' => true,
20 20
     ],
21 21
 ]);
22 22
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * @return json $response
40 40
  *
41 41
  */
42
-$app->get('/', function (Request $request, Response $response) use ($auth) {
42
+$app->get('/', function(Request $request, Response $response) use ($auth) {
43 43
     return $response->withJson(['status'], 404);
44 44
 
45 45
 });
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
  * @return json $response
55 55
  *
56 56
  */
57
-$app->post('/', function (Request $request, Response $response) {
57
+$app->post('/', function(Request $request, Response $response) {
58 58
     return $response->withJson(['status'], 404);
59 59
 
60 60
 });
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  * @return json $response
70 70
  *
71 71
  */
72
-$app->post('/auth/login', function (Request $request, Response $response) use ($auth) {
72
+$app->post('/auth/login', function(Request $request, Response $response) use ($auth) {
73 73
     return $auth->loginUser($request, $response);
74 74
 
75 75
 });
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
  *
88 88
  */
89 89
 
90
-$app->get('/auth/logout', function (Request $request, Response $response, $args) use ($auth) {
90
+$app->get('/auth/logout', function(Request $request, Response $response, $args) use ($auth) {
91 91
     return $auth->logoutUser($request, $response, $args)->withJson(['status'], 200);
92 92
 
93 93
 })->add(new Middleware());
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
  * @return json $response
103 103
  *
104 104
  */
105
-$app->get('/emojis', function (Request $request, Response $response, $args) use ($emoji) {
105
+$app->get('/emojis', function(Request $request, Response $response, $args) use ($emoji) {
106 106
     return $emoji->listAllEmoji($response);
107 107
 
108 108
 });
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
  * @return json $response
118 118
  *
119 119
  */
120
-$app->get('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) {
120
+$app->get('/emojis/{id}', function(Request $request, Response $response, $args) use ($emoji) {
121 121
     return  $emoji->getSingleEmoji($response, $args);
122 122
 
123 123
 });
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
  * @return json $response
133 133
  *
134 134
  */
135
-$app->post('/emojis', function (Request $request, Response $response) use ($emoji) {
135
+$app->post('/emojis', function(Request $request, Response $response) use ($emoji) {
136 136
     return $emoji->createEmoji($request, $response);
137 137
 
138 138
 })->add(new Middleware());
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
  * @return json $response
152 152
  *
153 153
  */
154
-$app->put('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) {
154
+$app->put('/emojis/{id}', function(Request $request, Response $response, $args) use ($emoji) {
155 155
     return $emoji->updateEmojiByPutVerb($request, $response, $args);
156 156
 
157 157
 })->add(new Middleware());
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
  * @return json $response
169 169
  *
170 170
  */
171
-$app->patch('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) {
171
+$app->patch('/emojis/{id}', function(Request $request, Response $response, $args) use ($emoji) {
172 172
     return $emoji->updateEmojiByPatchVerb($request, $response, $args);
173 173
 
174 174
 })->add(new Middleware());
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
  * @return json $response
186 186
  *
187 187
  */
188
-$app->delete('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) {
188
+$app->delete('/emojis/{id}', function(Request $request, Response $response, $args) use ($emoji) {
189 189
     return $emoji->deleteEmoji($request, $response, $args);
190 190
 
191 191
 })->add(new Middleware());
Please login to merge, or discard this patch.
src/Database/DatabaseConnection.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -48,15 +48,15 @@
 block discarded – undo
48 48
         $this->capsule->bootEloquent();
49 49
     }
50 50
 
51
-     /**
52
-      * Load Dotenv to grant getenv() access to
53
-      * environment variables in .env file.
54
-      */
55
-     public static function loadEnv()
56
-     {
57
-         if (!getenv('APP_ENV')) {
58
-             $dotenv = new Dotenv(__DIR__.'/../../');
59
-             $dotenv->load();
60
-         }
61
-     }
51
+        /**
52
+         * Load Dotenv to grant getenv() access to
53
+         * environment variables in .env file.
54
+         */
55
+        public static function loadEnv()
56
+        {
57
+            if (!getenv('APP_ENV')) {
58
+                $dotenv = new Dotenv(__DIR__.'/../../');
59
+                $dotenv->load();
60
+            }
61
+        }
62 62
 }
Please login to merge, or discard this patch.
src/Database/Schema.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author   Temitope Olotin <[email protected]>
4
- * @license  <https://opensource.org/license/MIT> MIT
5
- */
3
+         * @author   Temitope Olotin <[email protected]>
4
+         * @license  <https://opensource.org/license/MIT> MIT
5
+         */
6 6
 namespace Laztopaz\EmojiRestfulAPI;
7 7
 
8 8
 use Illuminate\Database\Capsule\Manager as Capsule;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function createUser()
27 27
     {
28
-        Capsule::schema()->create('users', function ($table) {
28
+        Capsule::schema()->create('users', function($table) {
29 29
             $table->increments('id');
30 30
             $table->string('firstname');
31 31
             $table->string('lastname');
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function createKeyword()
43 43
     {
44
-        Capsule::schema()->create('keywords', function ($table) {
44
+        Capsule::schema()->create('keywords', function($table) {
45 45
             $table->increments('id');
46 46
             $table->integer('emoji_id');
47 47
             $table->string('keyword_name');
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     public function createCategory()
56 56
     {
57
-        Capsule::schema()->create('categories', function ($table) {
57
+        Capsule::schema()->create('categories', function($table) {
58 58
             $table->increments('id');
59 59
             $table->string('category_name');
60 60
             $table->timestamps();
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function createEmoji()
68 68
     {
69
-        Capsule::schema()->create('emojis', function ($table) {
69
+        Capsule::schema()->create('emojis', function($table) {
70 70
             $table->increments('id');
71 71
             $table->string('name');
72 72
             $table->string('char');
Please login to merge, or discard this patch.
src/Model/User.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author   Temitope Olotin <[email protected]>
4
- * @license  <https://opensource.org/license/MIT> MIT
5
- */
3
+     * @author   Temitope Olotin <[email protected]>
4
+     * @license  <https://opensource.org/license/MIT> MIT
5
+     */
6 6
 namespace Laztopaz\EmojiRestfulAPI;
7 7
 
8 8
 use Illuminate\Database\Eloquent\Model;
Please login to merge, or discard this patch.
src/Model/Emoji.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author   Temitope Olotin <[email protected]>
4
- * @license  <https://opensource.org/license/MIT> MIT
5
- */
3
+     * @author   Temitope Olotin <[email protected]>
4
+     * @license  <https://opensource.org/license/MIT> MIT
5
+     */
6 6
 namespace Laztopaz\EmojiRestfulAPI;
7 7
 
8 8
 use Illuminate\Database\Eloquent\Model;
Please login to merge, or discard this patch.
src/Model/Category.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @author   Temitope Olotin <[email protected]>
4
- * @license  <https://opensource.org/license/MIT> MIT
5
- */
3
+     * @author   Temitope Olotin <[email protected]>
4
+     * @license  <https://opensource.org/license/MIT> MIT
5
+     */
6 6
 namespace Laztopaz\EmojiRestfulAPI;
7 7
 
8 8
 use Illuminate\Database\Eloquent\Model;
Please login to merge, or discard this patch.