@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -if (! function_exists('get_authenticated_user_id')) { |
|
4 | +if (!function_exists('get_authenticated_user_id')) { |
|
5 | 5 | function get_authenticated_user_id() |
6 | 6 | { |
7 | 7 | return get_authenticated_user()->id; |
8 | 8 | } |
9 | 9 | } |
10 | 10 | |
11 | -if (! function_exists('get_authenticated_user')) { |
|
11 | +if (!function_exists('get_authenticated_user')) { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @return \Modules\User\Entities\User |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | -if (! function_exists('get_short_class_name')) { |
|
26 | +if (!function_exists('get_short_class_name')) { |
|
27 | 27 | function get_short_class_name($class) |
28 | 28 | { |
29 | - if (! is_string($class)) { |
|
29 | + if (!is_string($class)) { |
|
30 | 30 | $class = get_class($class); |
31 | 31 | } |
32 | 32 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | -if (! function_exists('get_random_array_element')) { |
|
37 | +if (!function_exists('get_random_array_element')) { |
|
38 | 38 | function get_random_array_element(array $array) |
39 | 39 | { |
40 | 40 | if (empty($array)) { |
@@ -42,10 +42,10 @@ 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 | -if (! function_exists('create_multiple_from_factory')) { |
|
48 | +if (!function_exists('create_multiple_from_factory')) { |
|
49 | 49 | function create_multiple_from_factory(string $modelClass, $amount = 1, ?string $state = null) |
50 | 50 | { |
51 | 51 | if ($amount < 1) { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | -if (! function_exists('create_from_factory')) { |
|
65 | +if (!function_exists('create_from_factory')) { |
|
66 | 66 | function create_from_factory(string $modelClass, ?string $state = null) |
67 | 67 | { |
68 | 68 | $factory = factory($modelClass); |
@@ -75,33 +75,33 @@ discard block |
||
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | -if (! function_exists('class_implements_interface')) { |
|
78 | +if (!function_exists('class_implements_interface')) { |
|
79 | 79 | function class_implements_interface($class, $interface) |
80 | 80 | { |
81 | 81 | return in_array($interface, class_implements($class)); |
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | -if (! function_exists('class_uses_trait')) { |
|
85 | +if (!function_exists('class_uses_trait')) { |
|
86 | 86 | function class_uses_trait($class, string $trait) |
87 | 87 | { |
88 | - if (! is_string($class)) { |
|
88 | + if (!is_string($class)) { |
|
89 | 89 | $class = get_class($class); |
90 | 90 | } |
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 | -if (! function_exists('array_keys_exists')) { |
|
97 | +if (!function_exists('array_keys_exists')) { |
|
98 | 98 | function array_keys_exists(array $keys, array $arr) |
99 | 99 | { |
100 | - return ! array_diff_key(array_flip($keys), $arr); |
|
100 | + return !array_diff_key(array_flip($keys), $arr); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | -if (! function_exists('array_is_subset_of')) { |
|
104 | +if (!function_exists('array_is_subset_of')) { |
|
105 | 105 | function array_is_subset_of(array $subset, array $array, bool $strict = false) |
106 | 106 | { |
107 | 107 | $arrayAssociative = is_associative_array($array); |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | return $result; |
120 | - } elseif (($subsetAssociative && ! $arrayAssociative) || |
|
121 | - (! $subsetAssociative && $arrayAssociative)) { |
|
120 | + } elseif (($subsetAssociative && !$arrayAssociative) || |
|
121 | + (!$subsetAssociative && $arrayAssociative)) { |
|
122 | 122 | return false; |
123 | 123 | } |
124 | 124 | |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | -if (! function_exists('is_associative_array')) { |
|
135 | +if (!function_exists('is_associative_array')) { |
|
136 | 136 | function is_associative_array(array $arr) |
137 | 137 | { |
138 | - if ([] === $arr) { |
|
138 | + if ([ ] === $arr) { |
|
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | -if (! function_exists('get_class_property')) { |
|
146 | +if (!function_exists('get_class_property')) { |
|
147 | 147 | function get_class_property($class, string $property) |
148 | 148 | { |
149 | - if (! is_string($class)) { |
|
149 | + if (!is_string($class)) { |
|
150 | 150 | $class = get_class($class); |
151 | 151 | } |
152 | 152 | |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | -if (! function_exists('call_class_function')) { |
|
165 | +if (!function_exists('call_class_function')) { |
|
166 | 166 | function call_class_function($class, string $methodName) |
167 | 167 | { |
168 | - if (! is_string($class)) { |
|
168 | + if (!is_string($class)) { |
|
169 | 169 | $class = get_class($class); |
170 | 170 | } |
171 | 171 | |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | -if (! function_exists('get_class_constants')) { |
|
182 | +if (!function_exists('get_class_constants')) { |
|
183 | 183 | function get_class_constants($class) |
184 | 184 | { |
185 | - if (! is_string($class)) { |
|
185 | + if (!is_string($class)) { |
|
186 | 186 | $class = get_class($class); |
187 | 187 | } |
188 | 188 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * ModelCache constructor. |
26 | 26 | */ |
27 | - public function __construct(string $model, array $indexes = [], $cacheTime = null) |
|
27 | + public function __construct(string $model, array $indexes = [ ], $cacheTime = null) |
|
28 | 28 | { |
29 | 29 | $this->model = $model; |
30 | 30 | $this->secondaryIndexes = $indexes; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | public function findBy(string $index, $key, $eagerLoad = true) |
52 | 52 | { |
53 | - if (! in_array($index, $this->secondaryIndexes)) { |
|
53 | + if (!in_array($index, $this->secondaryIndexes)) { |
|
54 | 54 | throw new Exception('provided index does not exist as secondary index on the cache model'); |
55 | 55 | } |
56 | 56 | $modelId = $this->findSecondaryIndex($index, $key); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | protected function eagerLoadRelations($model) |
71 | 71 | { |
72 | 72 | if ($model !== null) { |
73 | - return $model::eagerLoadRelations([$model])[0]; |
|
73 | + return $model::eagerLoadRelations([ $model ])[ 0 ]; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | public function testCacheSpeed() |
21 | 21 | { |
22 | - $model = Account::create(['testthisshit' => 5]); |
|
22 | + $model = Account::create([ 'testthisshit' => 5 ]); |
|
23 | 23 | \Cache::forever('testmodel', $model); |
24 | 24 | |
25 | 25 | $time_db_start = microtime(true); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | return explode(',', $request->include); |
27 | 27 | } |
28 | 28 | |
29 | - return []; |
|
29 | + return [ ]; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | public function compileRelations() |
36 | 36 | { |
37 | 37 | $requestedRelations = $this->parseRequestIncludeParameter(); |
38 | - $relations = []; |
|
38 | + $relations = [ ]; |
|
39 | 39 | foreach ($requestedRelations as $requestedRelation) { |
40 | - if (isset($this->available[$requestedRelation])) { |
|
41 | - $relations[$requestedRelation] = $this->available[$requestedRelation]; |
|
40 | + if (isset($this->available[ $requestedRelation ])) { |
|
41 | + $relations[ $requestedRelation ] = $this->available[ $requestedRelation ]; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | $merge = array_merge($this->include, $relations); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if (is_array($relation)) { |
57 | 57 | $this->include = array_merge($this->include, $relation); |
58 | 58 | } else { |
59 | - $this->include[] = $relation; |
|
59 | + $this->include[ ] = $relation; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | return $this; |
@@ -64,21 +64,21 @@ discard block |
||
64 | 64 | |
65 | 65 | protected function includeRelations() |
66 | 66 | { |
67 | - $relations = []; |
|
67 | + $relations = [ ]; |
|
68 | 68 | if ($this->resource instanceof Model) { |
69 | 69 | $relations = $this->compileRelations(); |
70 | 70 | foreach ($relations as $relation => $transformer) { |
71 | 71 | $relationMethodName = 'transform'.ucfirst(strtolower($relation)); |
72 | 72 | if (method_exists($this, $relationMethodName)) { |
73 | - $relations[$relation] = $this->$relationMethodName($this->resource->$relation); |
|
73 | + $relations[ $relation ] = $this->$relationMethodName($this->resource->$relation); |
|
74 | 74 | } else { |
75 | 75 | if ($this->resource->$relation instanceof Model) { |
76 | - $relations[$relation] = $transformer::resource($this->whenLoaded($relation)); |
|
76 | + $relations[ $relation ] = $transformer::resource($this->whenLoaded($relation)); |
|
77 | 77 | } elseif ($this->resource->$relation instanceof Collection) { |
78 | - $relations[$relation] = $transformer::collection($this->whenLoaded($relation)); |
|
78 | + $relations[ $relation ] = $transformer::collection($this->whenLoaded($relation)); |
|
79 | 79 | } |
80 | - if($this->resource->$relation == null) |
|
81 | - $relations[$relation] = null; |
|
80 | + if ($this->resource->$relation == null) |
|
81 | + $relations[ $relation ] = null; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
@@ -77,8 +77,9 @@ |
||
77 | 77 | } elseif ($this->resource->$relation instanceof Collection) { |
78 | 78 | $relations[$relation] = $transformer::collection($this->whenLoaded($relation)); |
79 | 79 | } |
80 | - if($this->resource->$relation == null) |
|
81 | - $relations[$relation] = null; |
|
80 | + if($this->resource->$relation == null) { |
|
81 | + $relations[$relation] = null; |
|
82 | + } |
|
82 | 83 | } |
83 | 84 | } |
84 | 85 | } |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | private function loadRoutes() |
78 | 78 | { |
79 | 79 | foreach ($this->bootstrapService->getRoutes() as $route) { |
80 | - $path = $route['path']; |
|
81 | - $fileNameArray = explode('.', $route['filename']); |
|
82 | - $routePrefix = $fileNameArray[0]; |
|
83 | - $version = $fileNameArray[1]; |
|
80 | + $path = $route[ 'path' ]; |
|
81 | + $fileNameArray = explode('.', $route[ 'filename' ]); |
|
82 | + $routePrefix = $fileNameArray[ 0 ]; |
|
83 | + $version = $fileNameArray[ 1 ]; |
|
84 | 84 | |
85 | 85 | if ($version === 'php') { |
86 | 86 | $prefix = $routePrefix; |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | |
91 | 91 | Route::group([ |
92 | 92 | 'prefix' => $prefix, |
93 | - 'namespace' => $route['controller'], |
|
94 | - 'domain' => $route['domain'], |
|
95 | - 'middleware' => ['api'], |
|
96 | - ], function () use ($path) { |
|
93 | + 'namespace' => $route[ 'controller' ], |
|
94 | + 'domain' => $route[ 'domain' ], |
|
95 | + 'middleware' => [ 'api' ], |
|
96 | + ], function() use ($path) { |
|
97 | 97 | require $path; |
98 | 98 | }); |
99 | - Route::model($route['module'], $route['model']); |
|
99 | + Route::model($route[ 'module' ], $route[ 'model' ]); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | protected function loadConfigs() |
109 | 109 | { |
110 | 110 | foreach ($this->bootstrapService->getConfigs() as $config) { |
111 | - if (isset($config['filename']) && is_string($config['filename'])) { |
|
112 | - $fileName = $config['filename']; |
|
113 | - $configName = strtolower(explode('.', $fileName)[0]); |
|
111 | + if (isset($config[ 'filename' ]) && is_string($config[ 'filename' ])) { |
|
112 | + $fileName = $config[ 'filename' ]; |
|
113 | + $configName = strtolower(explode('.', $fileName)[ 0 ]); |
|
114 | 114 | $this->mergeConfigFrom( |
115 | - $config['path'], $configName |
|
115 | + $config[ 'path' ], $configName |
|
116 | 116 | ); |
117 | 117 | } |
118 | 118 | } |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | public function loadFactories() |
127 | 127 | { |
128 | 128 | foreach ($this->bootstrapService->getFactories() as $factory) { |
129 | - if (! $this->app->environment('production')) { |
|
130 | - app(Factory::class)->load($factory['path']); |
|
129 | + if (!$this->app->environment('production')) { |
|
130 | + app(Factory::class)->load($factory[ 'path' ]); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | public function loadMigrations() |
141 | 141 | { |
142 | 142 | foreach ($this->bootstrapService->getMigrations() as $migration) { |
143 | - $this->loadMigrationsFrom($migration['path']); |
|
143 | + $this->loadMigrationsFrom($migration[ 'path' ]); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | private function loadPolicies() |
148 | 148 | { |
149 | 149 | foreach ($this->bootstrapService->getPolicies() as $policy) { |
150 | - if (class_implements_interface($policy['class'], ModelPolicyContract::class)) { |
|
151 | - Gate::policy($policy['model'], $policy['class']); |
|
150 | + if (class_implements_interface($policy[ 'class' ], ModelPolicyContract::class)) { |
|
151 | + Gate::policy($policy[ 'model' ], $policy[ 'class' ]); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | { |
158 | 158 | $app = $this->app; |
159 | 159 | $service = $this->bootstrapService; |
160 | - $this->app->extend('command.seed', function () use ($app, $service) { |
|
161 | - return new SeedCommand($app['db'], $service); |
|
160 | + $this->app->extend('command.seed', function() use ($app, $service) { |
|
161 | + return new SeedCommand($app[ 'db' ], $service); |
|
162 | 162 | }); |
163 | 163 | } |
164 | 164 | |
@@ -193,15 +193,15 @@ discard block |
||
193 | 193 | private function loadListeners() |
194 | 194 | { |
195 | 195 | foreach ($this->bootstrapService->getEvents() as $event) { |
196 | - foreach ($event['listeners'] as $listener) { |
|
197 | - Event::listen($event['class'], $listener); |
|
196 | + foreach ($event[ 'listeners' ] as $listener) { |
|
197 | + Event::listen($event[ 'class' ], $listener); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | 202 | private function passedRegistrationCondition($class) |
203 | 203 | { |
204 | - if (! class_implements_interface($class, ConditionalAutoRegistration::class)) { |
|
204 | + if (!class_implements_interface($class, ConditionalAutoRegistration::class)) { |
|
205 | 205 | return true; |
206 | 206 | } |
207 | 207 |
@@ -28,8 +28,9 @@ |
||
28 | 28 | public function generate() |
29 | 29 | { |
30 | 30 | if (!$this->machineIsAvailable() && $this->appShouldRun()) { |
31 | - if ($this->applicationState->paused) |
|
32 | - return SynchronisationState::SCRIPT_PAUSED; |
|
31 | + if ($this->applicationState->paused) { |
|
32 | + return SynchronisationState::SCRIPT_PAUSED; |
|
33 | + } |
|
33 | 34 | return SynchronisationState::SCRIPT_RUNNING; |
34 | 35 | } |
35 | 36 | return SynchronisationState::CLIENT_STOPPED; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | $this->applicationState = $applicationState; |
28 | 28 | } |
29 | 29 | |
30 | - public function generate(){ |
|
30 | + public function generate() { |
|
31 | 31 | |
32 | 32 | } |
33 | 33 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @var array |
31 | 31 | */ |
32 | - protected $guarded = []; |
|
32 | + protected $guarded = [ ]; |
|
33 | 33 | |
34 | 34 | protected $casts = [ |
35 | 35 | 'active' => 'boolean', |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | protected static function boot() |
45 | 45 | { |
46 | 46 | parent::boot(); |
47 | - static::addGlobalScope('type', function (Builder $builder) { |
|
47 | + static::addGlobalScope('type', function(Builder $builder) { |
|
48 | 48 | $builder->where('type', get_short_class_name(static::class)); |
49 | 49 | }); |
50 | 50 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | { |
46 | 46 | return [ |
47 | 47 | 'id' => $app->id, |
48 | - 'alias' => $app->alias ?? $app->credentials['username'], |
|
48 | + 'alias' => $app->alias ?? $app->credentials[ 'username' ], |
|
49 | 49 | 'performance_mode' => array_random([ |
50 | 50 | 'EXTREME', |
51 | 51 | 'MEDIUM', |