@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | public static function cache(): ModelCache |
25 | 25 | { |
26 | - if (! isset(static::$caching)) { |
|
26 | + if (!isset(static::$caching)) { |
|
27 | 27 | static::$caching = new ModelCache(static::class, get_class_property(static::class, 'secondaryCacheIndexes'), get_class_property(static::class, 'cacheTime')); |
28 | 28 | } |
29 | 29 | |
30 | 30 | return static::$caching; |
31 | 31 | } |
32 | 32 | |
33 | - public static function find($id, $columns = ['*']) |
|
33 | + public static function find($id, $columns = [ '*' ]) |
|
34 | 34 | { |
35 | 35 | if (static::cache()->enabled()) { |
36 | 36 | $model = static::cache()->find($id) ?? static::recache($id); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | return $model; |
50 | 50 | } |
51 | 51 | |
52 | - public static function findWithoutCache($id, $columns = ['*']) |
|
52 | + public static function findWithoutCache($id, $columns = [ '*' ]) |
|
53 | 53 | { |
54 | 54 | $model = new static(); |
55 | 55 | if (is_array($id) || $id instanceof Arrayable) { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | - if ($columns !== ['*']) { |
|
68 | + if ($columns !== [ '*' ]) { |
|
69 | 69 | return collect($model)->first($columns); |
70 | 70 | } |
71 | 71 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() |
25 | 25 | { |
26 | - if (! isset($this->collection) || $this->collection === '') { |
|
26 | + if (!isset($this->collection) || $this->collection === '') { |
|
27 | 27 | throw new InternalErrorException('Collection name must be specified on migration: '.get_called_class()); |
28 | 28 | } |
29 | 29 | } |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | */ |
38 | 38 | final public function up() |
39 | 39 | { |
40 | - if (! Schema::connection($this->connection)->hasTable($this->collection)) { |
|
41 | - Schema::connection($this->connection)->create($this->collection, function (Blueprint $collection) { |
|
40 | + if (!Schema::connection($this->connection)->hasTable($this->collection)) { |
|
41 | + Schema::connection($this->connection)->create($this->collection, function(Blueprint $collection) { |
|
42 | 42 | $this->migrate($collection); |
43 | 43 | }); |
44 | 44 | } |
@@ -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 |
@@ -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); |
@@ -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', |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use Faker\Generator as Faker; |
4 | 4 | use Modules\Application\Entities\Application; |
5 | 5 | |
6 | -$factory->define(Application::class, function (Faker $faker) { |
|
6 | +$factory->define(Application::class, function(Faker $faker) { |
|
7 | 7 | return [ |
8 | 8 | 'alias' => null, |
9 | 9 | 'user_id' => 1, |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | ]; |
20 | 20 | }); |
21 | 21 | |
22 | -$factory->state(Application::class, 'OSRS', function (Faker $faker) { |
|
22 | +$factory->state(Application::class, 'OSRS', function(Faker $faker) { |
|
23 | 23 | return [ |
24 | 24 | 'type' => 'OSRS', |
25 | 25 | 'credentials' => [ |
@@ -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 | 80 | if ($this->resource->$relation == null) { |
81 | - $relations[$relation] = null; |
|
81 | + $relations[ $relation ] = null; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |