@@ -22,7 +22,7 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | public function toArray($request) |
| 24 | 24 | { |
| 25 | - $notification = (object)$this->data; |
|
| 25 | + $notification = (object) $this->data; |
|
| 26 | 26 | $resource = [ |
| 27 | 27 | 'id' => $this->getKey(), |
| 28 | 28 | 'title' => $notification->title, |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | public function boot() |
| 16 | 16 | { |
| 17 | 17 | Broadcast::routes([ |
| 18 | - 'middleware' => ['api'], |
|
| 18 | + 'middleware' => [ 'api' ], |
|
| 19 | 19 | 'domain' => env('API_URL'), |
| 20 | 20 | ]); |
| 21 | 21 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | class WebNotificationCreatedEvent extends BroadcastNotificationCreated |
| 15 | 15 | { |
| 16 | - public function broadcastAs(){ |
|
| 16 | + public function broadcastAs() { |
|
| 17 | 17 | return 'notification.created'; |
| 18 | 18 | } |
| 19 | 19 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | $randomIndex = random_int(0, count($array) - 1); |
| 44 | 44 | |
| 45 | - return $array[$randomIndex]; |
|
| 45 | + return $array[ $randomIndex ]; |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | if (!function_exists('create_multiple_from_factory')) { |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $traits = array_flip(class_uses_recursive($class)); |
| 93 | 93 | |
| 94 | - return isset($traits[$trait]); |
|
| 94 | + return isset($traits[ $trait ]); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | if (!function_exists('array_keys_exists')) { |
@@ -123,8 +123,9 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | $result = array_intersect($subset, $array); |
| 125 | 125 | |
| 126 | - if ($strict) |
|
| 127 | - return $result === $subset; |
|
| 126 | + if ($strict) { |
|
| 127 | + return $result === $subset; |
|
| 128 | + } |
|
| 128 | 129 | |
| 129 | 130 | return $result == $subset; |
| 130 | 131 | } |
@@ -133,7 +134,9 @@ discard block |
||
| 133 | 134 | if (!function_exists('is_associative_array')) { |
| 134 | 135 | function is_associative_array(array $arr) |
| 135 | 136 | { |
| 136 | - if (array() === $arr) return false; |
|
| 137 | + if (array() === $arr) { |
|
| 138 | + return false; |
|
| 139 | + } |
|
| 137 | 140 | return array_keys($arr) !== range(0, count($arr) - 1); |
| 138 | 141 | } |
| 139 | 142 | } |
@@ -28,6 +28,6 @@ |
||
| 28 | 28 | |
| 29 | 29 | public function receivesBroadcastNotificationsOn() |
| 30 | 30 | { |
| 31 | - return strtolower(get_short_class_name($this)) . '.' . $this->getKey(); |
|
| 31 | + return strtolower(get_short_class_name($this)).'.'.$this->getKey(); |
|
| 32 | 32 | } |
| 33 | 33 | } |
@@ -65,8 +65,9 @@ |
||
| 65 | 65 | |
| 66 | 66 | protected function decodeHttpContent($content, $unwrap = true) |
| 67 | 67 | { |
| 68 | - if ($unwrap) |
|
| 69 | - return json_decode($content, true)['data']; |
|
| 68 | + if ($unwrap) { |
|
| 69 | + return json_decode($content, true)['data']; |
|
| 70 | + } |
|
| 70 | 71 | return json_decode($content, true); |
| 71 | 72 | } |
| 72 | 73 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | private function getUserTokenData(): \stdClass |
| 46 | 46 | { |
| 47 | - return Cache::remember('testing:http_access_token', 60, function () { |
|
| 47 | + return Cache::remember('testing:http_access_token', 60, function() { |
|
| 48 | 48 | try { |
| 49 | 49 | $httpClient = new Client(); |
| 50 | 50 | $domain = 'https://astral.eu.auth0.com/'; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $username = env('AUTH0_TEST_USER_NAME'); |
| 54 | 54 | $password = env('AUTH0_TEST_USER_PASS'); |
| 55 | 55 | |
| 56 | - $response = $httpClient->post($domain . 'oauth/token', [ |
|
| 56 | + $response = $httpClient->post($domain.'oauth/token', [ |
|
| 57 | 57 | 'form_params' => [ |
| 58 | 58 | 'grant_type' => 'password', |
| 59 | 59 | 'client_id' => $clientId, |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | ]); |
| 65 | 65 | return json_decode($response->getBody()->getContents()); |
| 66 | 66 | } catch (ClientException $exception) { |
| 67 | - throw new Exception("Could not obtain token from Auth0 for testing from $test $domain $clientId $username $password" . $exception->getMessage()); |
|
| 67 | + throw new Exception("Could not obtain token from Auth0 for testing from $test $domain $clientId $username $password".$exception->getMessage()); |
|
| 68 | 68 | } |
| 69 | 69 | }); |
| 70 | 70 | } |
@@ -72,30 +72,30 @@ discard block |
||
| 72 | 72 | protected function decodeHttpContent($content, $unwrap = true) |
| 73 | 73 | { |
| 74 | 74 | if ($unwrap) |
| 75 | - return json_decode($content, true)['data']; |
|
| 75 | + return json_decode($content, true)[ 'data' ]; |
|
| 76 | 76 | return json_decode($content, true); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - protected function http(string $method, string $route, array $payload = []) |
|
| 79 | + protected function http(string $method, string $route, array $payload = [ ]) |
|
| 80 | 80 | { |
| 81 | 81 | return $this->sendRequest($method, $route, $payload, true); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - private function sendRequest(string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
| 84 | + private function sendRequest(string $method, string $route, array $payload = [ ], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
| 85 | 85 | { |
| 86 | - return $this->json($method, env('API_URL') . '/' . $route, $payload, $authenticated ? [ |
|
| 87 | - 'Authorization' => 'Bearer ' . $this->getUserTokenData()->id_token, |
|
| 88 | - ] : []); |
|
| 86 | + return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
|
| 87 | + 'Authorization' => 'Bearer '.$this->getUserTokenData()->id_token, |
|
| 88 | + ] : [ ]); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - protected function sendRequestWithToken($token, string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
| 91 | + protected function sendRequestWithToken($token, string $method, string $route, array $payload = [ ], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
| 92 | 92 | { |
| 93 | - return $this->json($method, env('API_URL') . '/' . $route, $payload, $authenticated ? [ |
|
| 94 | - 'Authorization' => 'Bearer ' . $token, |
|
| 95 | - ] : []); |
|
| 93 | + return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
|
| 94 | + 'Authorization' => 'Bearer '.$token, |
|
| 95 | + ] : [ ]); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - protected function httpNoAuth(string $method, string $route, array $payload = []) |
|
| 98 | + protected function httpNoAuth(string $method, string $route, array $payload = [ ]) |
|
| 99 | 99 | { |
| 100 | 100 | return $this->sendRequest($method, $route, $payload, false); |
| 101 | 101 | } |
@@ -14,23 +14,23 @@ |
||
| 14 | 14 | { |
| 15 | 15 | protected $connection = 'mysql'; |
| 16 | 16 | |
| 17 | - public static function find($id, $columns = ['*']) |
|
| 17 | + public static function find($id, $columns = [ '*' ]) |
|
| 18 | 18 | { |
| 19 | - if ((bool)config('model.caching')) { |
|
| 19 | + if ((bool) config('model.caching')) { |
|
| 20 | 20 | $model = ModelCache::findOrRequery($id, get_called_class()); |
| 21 | 21 | return self::filterFromColumns($model, $columns); |
| 22 | 22 | } |
| 23 | 23 | return self::findWithoutCache($id, $columns); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public static function findWithoutCache($id, $columns = ['*']) |
|
| 26 | + public static function findWithoutCache($id, $columns = [ '*' ]) |
|
| 27 | 27 | { |
| 28 | 28 | return parent::find($id, $columns); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | private static function filterFromColumns($model, $columns) |
| 32 | 32 | { |
| 33 | - if ($columns !== ['*']) { |
|
| 33 | + if ($columns !== [ '*' ]) { |
|
| 34 | 34 | return collect($model)->first($columns); |
| 35 | 35 | } |
| 36 | 36 | return $model; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $this->assertCount(2, $notifications); |
| 35 | 35 | $notification = $user->unreadNotifications()->first(); |
| 36 | 36 | $notificationId = $notification->getKey(); |
| 37 | - $response = $this->http('POST', 'v1/notifications/' . $notificationId); |
|
| 37 | + $response = $this->http('POST', 'v1/notifications/'.$notificationId); |
|
| 38 | 38 | $response->assertStatus(200); |
| 39 | 39 | $unreadnotifications = User::find($user->getKey())->unreadNotifications; |
| 40 | 40 | $this->assertCount(1, $unreadnotifications); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $response->assertStatus(200); |
| 50 | 50 | $notificationsReponse = $this->decodeHttpContent($response->getContent()); |
| 51 | 51 | $notifications = NotificationResource::collection(User::find($user->getKey())->notifications)->jsonSerialize(); |
| 52 | - $this->assertEquals($notificationsReponse, (array)$notifications); |
|
| 52 | + $this->assertEquals($notificationsReponse, (array) $notifications); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public function testUnreadNotificationsRoute() |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $user->notifyNow(new UserRegisteredNotification($user)); |
| 61 | 61 | $notification = $user->unreadNotifications()->first(); |
| 62 | 62 | $notificationId = $notification->getKey(); |
| 63 | - $response = $this->http('POST', 'v1/notifications/' . $notificationId); |
|
| 63 | + $response = $this->http('POST', 'v1/notifications/'.$notificationId); |
|
| 64 | 64 | $response->assertStatus(200); |
| 65 | 65 | $response = $this->http('GET', 'v1/notifications/unread'); |
| 66 | 66 | $response->assertStatus(200); |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $id = $user->getKey(); |
| 21 | 21 | $response = $this->http('POST', '/broadcasting/auth', [ |
| 22 | 22 | 'socket_id' => '125200.2991064', |
| 23 | - 'channel_name' => 'private-user.' . $id |
|
| 23 | + 'channel_name' => 'private-user.'.$id |
|
| 24 | 24 | ]); |
| 25 | 25 | $response->assertStatus(200); |
| 26 | 26 | $this->assertArrayHasKey('auth', $this->decodeHttpContent($response->content(), false)); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $response = $this->http('POST', '/broadcasting/auth', [ |
| 32 | 32 | 'socket_id' => '125200.2991064', |
| 33 | - 'channel_name' => 'private-user.' . new ObjectId() |
|
| 33 | + 'channel_name' => 'private-user.'.new ObjectId() |
|
| 34 | 34 | ]); |
| 35 | 35 | $response->assertStatus(403); |
| 36 | 36 | } |