@@ -5,90 +5,90 @@ |
||
5 | 5 | |
6 | 6 | $factory->define(Account::class, function (Faker $faker) { |
7 | 7 | return [ |
8 | - 'user_id' => 1, |
|
9 | - 'username' => $faker->unique()->safeEmail, |
|
10 | - 'password' => $faker->password, |
|
11 | - 'game' => 'OSRS', |
|
12 | - 'banned_at' => $faker->boolean(80) ? null : \Carbon\Carbon::now()->subHours($faker->numberBetween(1, 500)), |
|
13 | - 'last_heartbeat_at' => $faker->boolean(50) ? null : \Carbon\Carbon::now()->subSeconds($faker->numberBetween(1, 500)), |
|
14 | - 'performance_mode' => array_random([ |
|
15 | - 'EXTREME', |
|
16 | - 'MEDIUM', |
|
17 | - 'DISABLED', |
|
18 | - ]), |
|
19 | - 'logged_in' => $faker->boolean, |
|
20 | - 'machine_id' => 1, |
|
21 | - ]; |
|
8 | + 'user_id' => 1, |
|
9 | + 'username' => $faker->unique()->safeEmail, |
|
10 | + 'password' => $faker->password, |
|
11 | + 'game' => 'OSRS', |
|
12 | + 'banned_at' => $faker->boolean(80) ? null : \Carbon\Carbon::now()->subHours($faker->numberBetween(1, 500)), |
|
13 | + 'last_heartbeat_at' => $faker->boolean(50) ? null : \Carbon\Carbon::now()->subSeconds($faker->numberBetween(1, 500)), |
|
14 | + 'performance_mode' => array_random([ |
|
15 | + 'EXTREME', |
|
16 | + 'MEDIUM', |
|
17 | + 'DISABLED', |
|
18 | + ]), |
|
19 | + 'logged_in' => $faker->boolean, |
|
20 | + 'machine_id' => 1, |
|
21 | + ]; |
|
22 | 22 | }); |
23 | 23 | |
24 | - $factory->state(Account::class, 'OSRS', function (Faker $faker) { |
|
25 | - return [ |
|
26 | - 'game' => 'OSRS', |
|
27 | - 'bank_pin' => $faker->randomNumber(4, true), |
|
28 | - 'ingame_name' => $faker->userName, |
|
29 | - 'membership_expires_at' => $faker->boolean(80) ? null : \Carbon\Carbon::now()->addHours($faker->numberBetween(1, 500)), |
|
30 | - 'location' => [ |
|
31 | - 'x' => $faker->numberBetween(-10000, 10000), |
|
32 | - 'y' => $faker->numberBetween(-10000, 10000), |
|
33 | - 'z' => $faker->numberBetween(0, 3), |
|
34 | - ], |
|
35 | - 'skills' => [ |
|
36 | - 'hitpoints' => $faker->numberBetween(0, 200000000), |
|
37 | - 'attack' => $faker->numberBetween(0, 200000000), |
|
38 | - 'strength' => $faker->numberBetween(0, 200000000), |
|
39 | - 'defence' => $faker->numberBetween(0, 200000000), |
|
40 | - 'ranged' => $faker->numberBetween(0, 200000000), |
|
41 | - 'prayer' => $faker->numberBetween(0, 200000000), |
|
42 | - 'magic' => $faker->numberBetween(0, 200000000), |
|
43 | - 'runecrafting' => $faker->numberBetween(0, 200000000), |
|
44 | - 'crafting' => $faker->numberBetween(0, 200000000), |
|
45 | - 'mining' => $faker->numberBetween(0, 200000000), |
|
46 | - 'smithing' => $faker->numberBetween(0, 200000000), |
|
47 | - 'fishing' => $faker->numberBetween(0, 200000000), |
|
48 | - 'cooking' => $faker->numberBetween(0, 200000000), |
|
49 | - 'firemaking' => $faker->numberBetween(0, 200000000), |
|
50 | - 'woodcutting' => $faker->numberBetween(0, 200000000), |
|
51 | - 'agility' => $faker->numberBetween(0, 200000000), |
|
52 | - 'herblore' => $faker->numberBetween(0, 200000000), |
|
53 | - 'thieving' => $faker->numberBetween(0, 200000000), |
|
54 | - 'fletching' => $faker->numberBetween(0, 200000000), |
|
55 | - 'slayer' => $faker->numberBetween(0, 200000000), |
|
56 | - 'farming' => $faker->numberBetween(0, 200000000), |
|
57 | - 'construction' => $faker->numberBetween(0, 200000000), |
|
58 | - 'hunter' => $faker->numberBetween(0, 200000000), |
|
59 | - ], |
|
60 | - 'items' => [ |
|
61 | - 'bank' => [ |
|
62 | - [ |
|
63 | - 'item_id' => 5, |
|
64 | - 'amount' => 2, |
|
65 | - ], |
|
66 | - [ |
|
67 | - 'item_id' => 4, |
|
68 | - 'amount' => 3, |
|
69 | - ], |
|
70 | - [ |
|
71 | - 'item_id' => 2, |
|
72 | - 'amount' => 1, |
|
73 | - ], |
|
74 | - ], |
|
75 | - 'equipment' => [], |
|
76 | - 'grand_exchange' => [ |
|
77 | - [ |
|
78 | - 'item_id' => 5, |
|
79 | - 'amount' => 2, |
|
80 | - ], |
|
81 | - ], |
|
82 | - 'inventory' => [], |
|
83 | - ], |
|
84 | - ]; |
|
85 | - }); |
|
24 | + $factory->state(Account::class, 'OSRS', function (Faker $faker) { |
|
25 | + return [ |
|
26 | + 'game' => 'OSRS', |
|
27 | + 'bank_pin' => $faker->randomNumber(4, true), |
|
28 | + 'ingame_name' => $faker->userName, |
|
29 | + 'membership_expires_at' => $faker->boolean(80) ? null : \Carbon\Carbon::now()->addHours($faker->numberBetween(1, 500)), |
|
30 | + 'location' => [ |
|
31 | + 'x' => $faker->numberBetween(-10000, 10000), |
|
32 | + 'y' => $faker->numberBetween(-10000, 10000), |
|
33 | + 'z' => $faker->numberBetween(0, 3), |
|
34 | + ], |
|
35 | + 'skills' => [ |
|
36 | + 'hitpoints' => $faker->numberBetween(0, 200000000), |
|
37 | + 'attack' => $faker->numberBetween(0, 200000000), |
|
38 | + 'strength' => $faker->numberBetween(0, 200000000), |
|
39 | + 'defence' => $faker->numberBetween(0, 200000000), |
|
40 | + 'ranged' => $faker->numberBetween(0, 200000000), |
|
41 | + 'prayer' => $faker->numberBetween(0, 200000000), |
|
42 | + 'magic' => $faker->numberBetween(0, 200000000), |
|
43 | + 'runecrafting' => $faker->numberBetween(0, 200000000), |
|
44 | + 'crafting' => $faker->numberBetween(0, 200000000), |
|
45 | + 'mining' => $faker->numberBetween(0, 200000000), |
|
46 | + 'smithing' => $faker->numberBetween(0, 200000000), |
|
47 | + 'fishing' => $faker->numberBetween(0, 200000000), |
|
48 | + 'cooking' => $faker->numberBetween(0, 200000000), |
|
49 | + 'firemaking' => $faker->numberBetween(0, 200000000), |
|
50 | + 'woodcutting' => $faker->numberBetween(0, 200000000), |
|
51 | + 'agility' => $faker->numberBetween(0, 200000000), |
|
52 | + 'herblore' => $faker->numberBetween(0, 200000000), |
|
53 | + 'thieving' => $faker->numberBetween(0, 200000000), |
|
54 | + 'fletching' => $faker->numberBetween(0, 200000000), |
|
55 | + 'slayer' => $faker->numberBetween(0, 200000000), |
|
56 | + 'farming' => $faker->numberBetween(0, 200000000), |
|
57 | + 'construction' => $faker->numberBetween(0, 200000000), |
|
58 | + 'hunter' => $faker->numberBetween(0, 200000000), |
|
59 | + ], |
|
60 | + 'items' => [ |
|
61 | + 'bank' => [ |
|
62 | + [ |
|
63 | + 'item_id' => 5, |
|
64 | + 'amount' => 2, |
|
65 | + ], |
|
66 | + [ |
|
67 | + 'item_id' => 4, |
|
68 | + 'amount' => 3, |
|
69 | + ], |
|
70 | + [ |
|
71 | + 'item_id' => 2, |
|
72 | + 'amount' => 1, |
|
73 | + ], |
|
74 | + ], |
|
75 | + 'equipment' => [], |
|
76 | + 'grand_exchange' => [ |
|
77 | + [ |
|
78 | + 'item_id' => 5, |
|
79 | + 'amount' => 2, |
|
80 | + ], |
|
81 | + ], |
|
82 | + 'inventory' => [], |
|
83 | + ], |
|
84 | + ]; |
|
85 | + }); |
|
86 | 86 | |
87 | - $factory->state(Account::class, 'RS3', function (Faker $faker) { |
|
88 | - return [ |
|
89 | - 'game' => 'RS3', |
|
90 | - 'bank_pin' => $faker->randomNumber(4, true), |
|
91 | - 'ingame_name' => $faker->userName, |
|
92 | - 'membership_expires_at' => null, |
|
93 | - ]; |
|
94 | - }); |
|
87 | + $factory->state(Account::class, 'RS3', function (Faker $faker) { |
|
88 | + return [ |
|
89 | + 'game' => 'RS3', |
|
90 | + 'bank_pin' => $faker->randomNumber(4, true), |
|
91 | + 'ingame_name' => $faker->userName, |
|
92 | + 'membership_expires_at' => null, |
|
93 | + ]; |
|
94 | + }); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use Faker\Generator as Faker; |
4 | 4 | use Modules\Account\Entities\Account; |
5 | 5 | |
6 | -$factory->define(Account::class, function (Faker $faker) { |
|
6 | +$factory->define(Account::class, function(Faker $faker) { |
|
7 | 7 | return [ |
8 | 8 | 'user_id' => 1, |
9 | 9 | 'username' => $faker->unique()->safeEmail, |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | ]; |
22 | 22 | }); |
23 | 23 | |
24 | - $factory->state(Account::class, 'OSRS', function (Faker $faker) { |
|
24 | + $factory->state(Account::class, 'OSRS', function(Faker $faker) { |
|
25 | 25 | return [ |
26 | 26 | 'game' => 'OSRS', |
27 | 27 | 'bank_pin' => $faker->randomNumber(4, true), |
@@ -72,19 +72,19 @@ discard block |
||
72 | 72 | 'amount' => 1, |
73 | 73 | ], |
74 | 74 | ], |
75 | - 'equipment' => [], |
|
75 | + 'equipment' => [ ], |
|
76 | 76 | 'grand_exchange' => [ |
77 | 77 | [ |
78 | 78 | 'item_id' => 5, |
79 | 79 | 'amount' => 2, |
80 | 80 | ], |
81 | 81 | ], |
82 | - 'inventory' => [], |
|
82 | + 'inventory' => [ ], |
|
83 | 83 | ], |
84 | 84 | ]; |
85 | 85 | }); |
86 | 86 | |
87 | - $factory->state(Account::class, 'RS3', function (Faker $faker) { |
|
87 | + $factory->state(Account::class, 'RS3', function(Faker $faker) { |
|
88 | 88 | return [ |
89 | 89 | 'game' => 'RS3', |
90 | 90 | 'bank_pin' => $faker->randomNumber(4, true), |
@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | public function transformResource(DatabaseNotification $notification) |
17 | 17 | { |
18 | - $notificationData = (object)$notification->data; |
|
18 | + $notificationData = (object) $notification->data; |
|
19 | 19 | return [ |
20 | 20 | 'id' => $notification->getKey(), |
21 | 21 | 'title' => $notificationData->title, |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public function __construct($user) |
64 | 64 | { |
65 | 65 | $this->user = $user; |
66 | - parent::__construct([]); |
|
66 | + parent::__construct([ ]); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | { |
76 | 76 | public function toArray($request) |
77 | 77 | { |
78 | - return []; |
|
78 | + return [ ]; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public function transformUser(MachineTestModel $machine) |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | |
87 | 87 | class UserIncludedMachineTestTransformer extends MachineTestTransformer |
88 | 88 | { |
89 | - public $include = ['user']; |
|
89 | + public $include = [ 'user' ]; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | class UserTestTransformer extends Transformer |
93 | 93 | { |
94 | 94 | public function toArray($request) |
95 | 95 | { |
96 | - return []; |
|
96 | + return [ ]; |
|
97 | 97 | } |
98 | 98 | } |
@@ -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,18 +64,18 @@ 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 | } |
81 | 81 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | private static function loadRelations($resource, $extraRelations) |
88 | 88 | { |
89 | 89 | if ($resource instanceof Model || $resource instanceof Collection) { |
90 | - $relations = (array)call_class_function(static::class, 'compileRelations'); |
|
90 | + $relations = (array) call_class_function(static::class, 'compileRelations'); |
|
91 | 91 | $relations = array_merge($relations, $extraRelations); |
92 | 92 | $resource->loadMissing(array_keys($relations)); |
93 | 93 | } |
@@ -29,27 +29,27 @@ discard block |
||
29 | 29 | { |
30 | 30 | use IncludesRelations, HandlesLimit; |
31 | 31 | |
32 | - public $include = []; |
|
32 | + public $include = [ ]; |
|
33 | 33 | |
34 | - public $available = []; |
|
34 | + public $available = [ ]; |
|
35 | 35 | |
36 | 36 | public $limit = -1; |
37 | 37 | |
38 | - public function __construct($resource, $relations = []) |
|
38 | + public function __construct($resource, $relations = [ ]) |
|
39 | 39 | { |
40 | 40 | if (!($resource instanceof Model)) |
41 | 41 | throw new Exception('Object passed to the transformer resource method is not a eloquent model', 500); |
42 | 42 | $this->resource = $resource; |
43 | - $relations = is_array($relations) ? $relations : []; |
|
43 | + $relations = is_array($relations) ? $relations : [ ]; |
|
44 | 44 | parent::__construct(self::loadRelations($resource, $relations)); |
45 | 45 | } |
46 | 46 | |
47 | - public static function resource($model, array $relations = []): self |
|
47 | + public static function resource($model, array $relations = [ ]): self |
|
48 | 48 | { |
49 | 49 | return new static($model, $relations); |
50 | 50 | } |
51 | 51 | |
52 | - public static function collection($resource, array $relations = []) |
|
52 | + public static function collection($resource, array $relations = [ ]) |
|
53 | 53 | { |
54 | 54 | if (!($resource instanceof Collection)) |
55 | 55 | throw new Exception('Object passed to the transformer collection method is not a collection', 500); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function toArray($request) |
69 | 69 | { |
70 | 70 | if (!method_exists($this, 'transformResource')) |
71 | - throw new \Exception("transformResource method not set on " . static::class, 500); |
|
71 | + throw new \Exception("transformResource method not set on ".static::class, 500); |
|
72 | 72 | return array_merge($this->transformResource($this->resource), $this->includeRelations()); |
73 | 73 | } |
74 | 74 | } |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | |
38 | 38 | public function __construct($resource, $relations = []) |
39 | 39 | { |
40 | - if (!($resource instanceof Model)) |
|
41 | - throw new Exception('Object passed to the transformer resource method is not a eloquent model', 500); |
|
40 | + if (!($resource instanceof Model)) { |
|
41 | + throw new Exception('Object passed to the transformer resource method is not a eloquent model', 500); |
|
42 | + } |
|
42 | 43 | $this->resource = $resource; |
43 | 44 | $relations = is_array($relations) ? $relations : []; |
44 | 45 | parent::__construct(self::loadRelations($resource, $relations)); |
@@ -51,8 +52,9 @@ discard block |
||
51 | 52 | |
52 | 53 | public static function collection($resource, array $relations = []) |
53 | 54 | { |
54 | - if (!($resource instanceof Collection)) |
|
55 | - throw new Exception('Object passed to the transformer collection method is not a collection', 500); |
|
55 | + if (!($resource instanceof Collection)) { |
|
56 | + throw new Exception('Object passed to the transformer collection method is not a collection', 500); |
|
57 | + } |
|
56 | 58 | |
57 | 59 | $resource = self::processLimit($resource); |
58 | 60 | $resource = self::loadRelations($resource, $relations); |
@@ -67,8 +69,9 @@ discard block |
||
67 | 69 | |
68 | 70 | public function toArray($request) |
69 | 71 | { |
70 | - if (!method_exists($this, 'transformResource')) |
|
71 | - throw new \Exception("transformResource method not set on " . static::class, 500); |
|
72 | + if (!method_exists($this, 'transformResource')) { |
|
73 | + throw new \Exception("transformResource method not set on " . static::class, 500); |
|
74 | + } |
|
72 | 75 | return array_merge($this->transformResource($this->resource), $this->includeRelations()); |
73 | 76 | } |
74 | 77 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | $limit = call_class_function($class,'getLimitParameter'); |
48 | 48 | if($limit === -1) |
49 | 49 | return $resource; |
50 | - return $resource->take((int) $limit); |
|
50 | + return $resource->take((int) $limit); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | $request = request(); |
25 | 25 | if (isset($request->limit) && is_numeric($request->limit)) { |
26 | - return (int)$request->limit; |
|
26 | + return (int) $request->limit; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | return -1; |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | return $requestedLimit; |
43 | 43 | } |
44 | 44 | |
45 | - private static function processLimit(Collection $resource){ |
|
45 | + private static function processLimit(Collection $resource) { |
|
46 | 46 | $class = static::class; |
47 | - $limit = call_class_function($class,'getLimitParameter'); |
|
48 | - if($limit === -1) |
|
47 | + $limit = call_class_function($class, 'getLimitParameter'); |
|
48 | + if ($limit === -1) |
|
49 | 49 | return $resource; |
50 | 50 | return $resource->take((int) $limit); |
51 | 51 | } |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $requestedLimit = $this->parseRequestLimitParameter(); |
35 | 35 | $maxLimit = $this->limit; |
36 | 36 | |
37 | - if ($maxLimit === -1) |
|
38 | - return $requestedLimit; |
|
39 | - elseif ($requestedLimit > $maxLimit) { |
|
37 | + if ($maxLimit === -1) { |
|
38 | + return $requestedLimit; |
|
39 | + } elseif ($requestedLimit > $maxLimit) { |
|
40 | 40 | return $maxLimit; |
41 | 41 | } |
42 | 42 | return $requestedLimit; |
@@ -45,8 +45,9 @@ discard block |
||
45 | 45 | private static function processLimit(Collection $resource){ |
46 | 46 | $class = static::class; |
47 | 47 | $limit = call_class_function($class,'getLimitParameter'); |
48 | - if($limit === -1) |
|
49 | - return $resource; |
|
48 | + if($limit === -1) { |
|
49 | + return $resource; |
|
50 | + } |
|
50 | 51 | return $resource->take((int) $limit); |
51 | 52 | } |
52 | 53 |