@@ -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,11 +44,11 @@ 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 = env('AUTH0_DOMAIN'); |
51 | - $response = $httpClient->post($domain . 'oauth/token', [ |
|
51 | + $response = $httpClient->post($domain.'oauth/token', [ |
|
52 | 52 | 'form_params' => [ |
53 | 53 | 'grant_type' => 'password', |
54 | 54 | 'client_id' => env('AUTH0_CLIENT_ID'), |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ]); |
60 | 60 | return json_decode($response->getBody()->getContents()); |
61 | 61 | } catch (ClientException $exception) { |
62 | - throw new Exception("Could not obtain token from Auth0 for testing from $domain" . $exception->getMessage()); |
|
62 | + throw new Exception("Could not obtain token from Auth0 for testing from $domain".$exception->getMessage()); |
|
63 | 63 | } |
64 | 64 | }); |
65 | 65 | } |
@@ -67,30 +67,30 @@ discard block |
||
67 | 67 | protected function decodeHttpContent($content, $unwrap = true) |
68 | 68 | { |
69 | 69 | if ($unwrap) |
70 | - return json_decode($content, true)['data']; |
|
70 | + return json_decode($content, true)[ 'data' ]; |
|
71 | 71 | return json_decode($content, true); |
72 | 72 | } |
73 | 73 | |
74 | - protected function http(string $method, string $route, array $payload = []) |
|
74 | + protected function http(string $method, string $route, array $payload = [ ]) |
|
75 | 75 | { |
76 | 76 | return $this->sendRequest($method, $route, $payload, true); |
77 | 77 | } |
78 | 78 | |
79 | - private function sendRequest(string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
79 | + private function sendRequest(string $method, string $route, array $payload = [ ], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
80 | 80 | { |
81 | - return $this->json($method, env('API_URL') . '/' . $route, $payload, $authenticated ? [ |
|
82 | - 'Authorization' => 'Bearer ' . $this->getUserTokenData()->id_token, |
|
83 | - ] : []); |
|
81 | + return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
|
82 | + 'Authorization' => 'Bearer '.$this->getUserTokenData()->id_token, |
|
83 | + ] : [ ]); |
|
84 | 84 | } |
85 | 85 | |
86 | - protected function sendRequestWithToken($token, string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
86 | + protected function sendRequestWithToken($token, string $method, string $route, array $payload = [ ], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
87 | 87 | { |
88 | - return $this->json($method, env('API_URL') . '/' . $route, $payload, $authenticated ? [ |
|
89 | - 'Authorization' => 'Bearer ' . $token, |
|
90 | - ] : []); |
|
88 | + return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
|
89 | + 'Authorization' => 'Bearer '.$token, |
|
90 | + ] : [ ]); |
|
91 | 91 | } |
92 | 92 | |
93 | - protected function httpNoAuth(string $method, string $route, array $payload = []) |
|
93 | + protected function httpNoAuth(string $method, string $route, array $payload = [ ]) |
|
94 | 94 | { |
95 | 95 | return $this->sendRequest($method, $route, $payload, false); |
96 | 96 | } |
@@ -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 | } |