@@ -30,30 +30,30 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | use IncludesRelations, HandlesLimit; |
| 32 | 32 | |
| 33 | - public $include = []; |
|
| 33 | + public $include = [ ]; |
|
| 34 | 34 | |
| 35 | - public $available = []; |
|
| 35 | + public $available = [ ]; |
|
| 36 | 36 | |
| 37 | 37 | public $limit = -1; |
| 38 | 38 | |
| 39 | - public function __construct($resource, $relations = []) |
|
| 39 | + public function __construct($resource, $relations = [ ]) |
|
| 40 | 40 | { |
| 41 | - if (! ($resource instanceof Model)) { |
|
| 41 | + if (!($resource instanceof Model)) { |
|
| 42 | 42 | throw new Exception('Object passed to the transformer resource method is not a eloquent model', 500); |
| 43 | 43 | } |
| 44 | 44 | $this->resource = $resource; |
| 45 | - $relations = is_array($relations) ? $relations : []; |
|
| 45 | + $relations = is_array($relations) ? $relations : [ ]; |
|
| 46 | 46 | parent::__construct(self::loadRelations($resource, $relations)); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public static function resource($model, array $relations = []): self |
|
| 49 | + public static function resource($model, array $relations = [ ]): self |
|
| 50 | 50 | { |
| 51 | 51 | return new static($model, $relations); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public static function collection($resource, array $relations = []) |
|
| 54 | + public static function collection($resource, array $relations = [ ]) |
|
| 55 | 55 | { |
| 56 | - if (! ($resource instanceof Collection)) { |
|
| 56 | + if (!($resource instanceof Collection)) { |
|
| 57 | 57 | throw new Exception('Object passed to the transformer collection method is not a collection', 500); |
| 58 | 58 | } |
| 59 | 59 | $resource = self::processLimit($resource); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | public function toArray($request) |
| 71 | 71 | { |
| 72 | - if (! method_exists($this, 'transformResource')) { |
|
| 72 | + if (!method_exists($this, 'transformResource')) { |
|
| 73 | 73 | throw new \Exception('transformResource method not set on '.static::class, 500); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -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); |