@@ -1,8 +1,8 @@ |
||
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 | |
7 | 7 | namespace Laztopaz\EmojiRestfulAPI; |
8 | 8 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $authHeader = $request->getHeader('HTTP_AUTHORIZATION'); |
19 | 19 | |
20 | 20 | try { |
21 | - if (is_array($authHeader) && ! empty($authHeader)) { |
|
21 | + if (is_array($authHeader) && !empty($authHeader)) { |
|
22 | 22 | $secretKey = base64_decode(getenv('secret')); |
23 | 23 | $jwt = json_decode($authHeader[0], true); |
24 | 24 | //decode the JWT using the key from config |
@@ -1,8 +1,8 @@ |
||
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 | |
7 | 7 | namespace Laztopaz\EmojiRestfulAPI; |
8 | 8 |
@@ -1,8 +1,8 @@ |
||
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 | |
7 | 7 | namespace Laztopaz\EmojiRestfulAPI; |
8 | 8 |
@@ -1,8 +1,8 @@ |
||
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 | |
7 | 7 | namespace Laztopaz\EmojiRestfulAPI; |
8 | 8 |
@@ -1,8 +1,8 @@ |
||
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 | |
7 | 7 | namespace Laztopaz\EmojiRestfulAPI; |
8 | 8 |
@@ -51,9 +51,9 @@ |
||
51 | 51 | /** |
52 | 52 | * This method creates user |
53 | 53 | * |
54 | - * @param $user |
|
54 | + * @param UserController $user |
|
55 | 55 | * @param $userParams |
56 | - * @param $response |
|
56 | + * @param Response $response |
|
57 | 57 | * |
58 | 58 | * @return json $response |
59 | 59 | */ |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $user = User::where('username', '=', $loginParams['username'])->get()->first(); |
91 | 91 | |
92 | 92 | if (count($user) > 0) { |
93 | - $userInfo = ['id' => $user->id,]; |
|
93 | + $userInfo = ['id' => $user->id, ]; |
|
94 | 94 | |
95 | 95 | if (password_verify($loginParams['password'], $user->password)) { |
96 | 96 | $token = $this->buildAcessToken($userInfo); |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | * Create the token params as an array |
162 | 162 | */ |
163 | 163 | $data = [ |
164 | - 'iat' => $issuedAt, // Issued at: time when the token was generated |
|
165 | - 'jti' => $tokenId, // Json Token Id: an unique identifier for the token |
|
166 | - 'iss' => $serverName, // Issuer |
|
167 | - 'nbf' => $notBefore, // Not before |
|
168 | - 'exp' => $expire, // Expire |
|
169 | - 'dat' => $userData, // User Information retrieved from the database |
|
164 | + 'iat' => $issuedAt, // Issued at: time when the token was generated |
|
165 | + 'jti' => $tokenId, // Json Token Id: an unique identifier for the token |
|
166 | + 'iss' => $serverName, // Issuer |
|
167 | + 'nbf' => $notBefore, // Not before |
|
168 | + 'exp' => $expire, // Expire |
|
169 | + 'dat' => $userData, // User Information retrieved from the database |
|
170 | 170 | ]; |
171 | 171 | |
172 | 172 | $loadEnv = DatabaseConnection::loadEnv(); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $secretKey = base64_decode(getenv('secret')); |
175 | 175 | |
176 | 176 | $jwt = JWT::encode( |
177 | - $data, //Data to be encoded in the JWT |
|
177 | + $data, //Data to be encoded in the JWT |
|
178 | 178 | $secretKey, // The signing key |
179 | 179 | 'HS512' // Algorithm used to sign the token |
180 | 180 | ); |
@@ -1,8 +1,8 @@ |
||
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 | |
7 | 7 | namespace Laztopaz\EmojiRestfulAPI; |
8 | 8 |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | */ |
26 | 26 | public function createUser() |
27 | 27 | { |
28 | - if (! Capsule::schema()->hasTable('users')) { |
|
29 | - Capsule::schema()->create('users', function ($table) { |
|
28 | + if (!Capsule::schema()->hasTable('users')) { |
|
29 | + Capsule::schema()->create('users', function($table) { |
|
30 | 30 | $table->increments('id'); |
31 | 31 | $table->string('firstname'); |
32 | 32 | $table->string('lastname'); |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function createKeyword() |
45 | 45 | { |
46 | - if (! Capsule::schema()->hasTable('keywords')) { |
|
47 | - Capsule::schema()->create('keywords', function ($table) { |
|
46 | + if (!Capsule::schema()->hasTable('keywords')) { |
|
47 | + Capsule::schema()->create('keywords', function($table) { |
|
48 | 48 | $table->increments('id'); |
49 | 49 | $table->integer('emoji_id'); |
50 | 50 | $table->string('keyword_name'); |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function createCategory() |
60 | 60 | { |
61 | - if (! Capsule::schema()->hasTable('categories')) { |
|
62 | - Capsule::schema()->create('categories', function ($table) { |
|
61 | + if (!Capsule::schema()->hasTable('categories')) { |
|
62 | + Capsule::schema()->create('categories', function($table) { |
|
63 | 63 | $table->increments('id'); |
64 | 64 | $table->string('category_name'); |
65 | 65 | $table->timestamps(); |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function createEmoji() |
75 | 75 | { |
76 | - if (! Capsule::schema()->hasTable('emojis')) { |
|
77 | - Capsule::schema()->create('emojis', function ($table) { |
|
76 | + if (!Capsule::schema()->hasTable('emojis')) { |
|
77 | + Capsule::schema()->create('emojis', function($table) { |
|
78 | 78 | $table->increments('id'); |
79 | 79 | $table->string('name'); |
80 | 80 | $table->string('char'); |
@@ -1,8 +1,8 @@ discard block |
||
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 | |
7 | 7 | namespace Laztopaz\EmojiRestfulAPI; |
8 | 8 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $auth = $this->auth; |
47 | 47 | $emoji = $this->emoji; |
48 | 48 | |
49 | - /* |
|
49 | + /* |
|
50 | 50 | * This verb returns error 404 |
51 | 51 | * |
52 | 52 | * @param $request |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return json $response |
50 | 50 | * |
51 | 51 | */ |
52 | - $this->slimApp->get('/', function (Request $request, Response $response) { |
|
52 | + $this->slimApp->get('/', function(Request $request, Response $response) { |
|
53 | 53 | return $response->withJson(['message' => 'Welcome to Sweet Emoji'], 200); |
54 | 54 | |
55 | 55 | }); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return json $response |
65 | 65 | * |
66 | 66 | */ |
67 | - $this->slimApp->post('/', function (Request $request, Response $response) { |
|
67 | + $this->slimApp->post('/', function(Request $request, Response $response) { |
|
68 | 68 | return $response->withStatus(404); |
69 | 69 | |
70 | 70 | }); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return json $response |
80 | 80 | * |
81 | 81 | */ |
82 | - $this->slimApp->post('/auth/register', function (Request $request, Response $response) use ($auth) { |
|
82 | + $this->slimApp->post('/auth/register', function(Request $request, Response $response) use ($auth) { |
|
83 | 83 | return $auth->registerUser($request, $response); |
84 | 84 | |
85 | 85 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return json $response |
96 | 96 | * |
97 | 97 | */ |
98 | - $this->slimApp->post('/auth/login', function (Request $request, Response $response) use ($auth) { |
|
98 | + $this->slimApp->post('/auth/login', function(Request $request, Response $response) use ($auth) { |
|
99 | 99 | return $auth->loginUser($request, $response); |
100 | 100 | |
101 | 101 | }); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | */ |
115 | 115 | |
116 | - $this->slimApp->get('/auth/logout', function (Request $request, Response $response, $args) use ($auth) { |
|
116 | + $this->slimApp->get('/auth/logout', function(Request $request, Response $response, $args) use ($auth) { |
|
117 | 117 | return $auth->logoutUser($request, $response, $args); |
118 | 118 | |
119 | 119 | })->add(new Middleware()); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return json $response |
129 | 129 | * |
130 | 130 | */ |
131 | - $this->slimApp->get('/emojis', function (Request $request, Response $response) use ($emoji) { |
|
131 | + $this->slimApp->get('/emojis', function(Request $request, Response $response) use ($emoji) { |
|
132 | 132 | return $emoji->listAllEmoji($response); |
133 | 133 | |
134 | 134 | }); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return json $response |
144 | 144 | * |
145 | 145 | */ |
146 | - $this->slimApp->get('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) { |
|
146 | + $this->slimApp->get('/emojis/{id}', function(Request $request, Response $response, $args) use ($emoji) { |
|
147 | 147 | return $emoji->getSingleEmoji($response, $args); |
148 | 148 | |
149 | 149 | }); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return json $response |
159 | 159 | * |
160 | 160 | */ |
161 | - $this->slimApp->post('/emojis', function (Request $request, Response $response) use ($emoji) { |
|
161 | + $this->slimApp->post('/emojis', function(Request $request, Response $response) use ($emoji) { |
|
162 | 162 | return $emoji->createEmoji($request, $response); |
163 | 163 | |
164 | 164 | })->add(new Middleware()); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @return json $response |
178 | 178 | * |
179 | 179 | */ |
180 | - $this->slimApp->put('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) { |
|
180 | + $this->slimApp->put('/emojis/{id}', function(Request $request, Response $response, $args) use ($emoji) { |
|
181 | 181 | return $emoji->updateEmojiByPutVerb($request, $response, $args); |
182 | 182 | |
183 | 183 | })->add(new Middleware()); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @return json $response |
195 | 195 | * |
196 | 196 | */ |
197 | - $this->slimApp->patch('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) { |
|
197 | + $this->slimApp->patch('/emojis/{id}', function(Request $request, Response $response, $args) use ($emoji) { |
|
198 | 198 | return $emoji->updateEmojiByPatchVerb($request, $response, $args); |
199 | 199 | |
200 | 200 | })->add(new Middleware()); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @return json $response |
212 | 212 | * |
213 | 213 | */ |
214 | - $this->slimApp->delete('/emojis/{id}', function (Request $request, Response $response, $args) use ($emoji) { |
|
214 | + $this->slimApp->delete('/emojis/{id}', function(Request $request, Response $response, $args) use ($emoji) { |
|
215 | 215 | return $emoji->deleteEmoji($request, $response, $args); |
216 | 216 | |
217 | 217 | })->add(new Middleware()); |
@@ -1,8 +1,8 @@ |
||
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 | |
7 | 7 | namespace Laztopaz\EmojiRestfulAPI; |
8 | 8 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | * |
13 | 13 | * @param $data |
14 | 14 | * |
15 | - * @return bool true |
|
15 | + * @return boolean|null true |
|
16 | 16 | */ |
17 | 17 | public function createUser(array $data) |
18 | 18 | { |
@@ -1,8 +1,8 @@ |
||
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 | |
7 | 7 | namespace Laztopaz\EmojiRestfulAPI; |
8 | 8 |
@@ -74,6 +74,9 @@ |
||
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | + /** |
|
78 | + * @param string $keywords |
|
79 | + */ |
|
77 | 80 | public function createEmojiKeywords($emoji_id, $keywords) |
78 | 81 | { |
79 | 82 | if ($keywords) { |