@@ -99,13 +99,13 @@ |
||
99 | 99 | protected function configurationFor($name) |
100 | 100 | { |
101 | 101 | $config = $this->container['config']["control.export.{$name}"]; |
102 | - if(is_null($config)) { |
|
102 | + if (is_null($config)) { |
|
103 | 103 | return null; |
104 | 104 | } |
105 | - if(!isset($config['formatters'])) { |
|
105 | + if (!isset($config['formatters'])) { |
|
106 | 106 | $config['formatters'] = []; |
107 | 107 | } |
108 | - foreach($this->formatters() as $formatter => $formatterConfig) { |
|
108 | + foreach ($this->formatters() as $formatter => $formatterConfig) { |
|
109 | 109 | $config['formatters'][$formatter] = $formatterConfig; |
110 | 110 | } |
111 | 111 |
@@ -15,19 +15,19 @@ |
||
15 | 15 | usort($items, function($a, $b) use ($column) { |
16 | 16 | $aVal = $a->getItem($column); |
17 | 17 | $bVal = $b->getItem($column); |
18 | - if(is_null($aVal) && is_null($bVal)) { |
|
18 | + if (is_null($aVal) && is_null($bVal)) { |
|
19 | 19 | return 0; |
20 | 20 | } |
21 | - if(is_null($aVal) && !is_null($bVal)) { |
|
21 | + if (is_null($aVal) && !is_null($bVal)) { |
|
22 | 22 | return 1; |
23 | 23 | } |
24 | - if(!is_null($aVal) && is_null($bVal)) { |
|
24 | + if (!is_null($aVal) && is_null($bVal)) { |
|
25 | 25 | return -1; |
26 | 26 | } |
27 | - if(is_string($aVal) || is_string($bVal)) { |
|
27 | + if (is_string($aVal) || is_string($bVal)) { |
|
28 | 28 | return $this->compareStrings($aVal, $bVal); |
29 | 29 | } |
30 | - if(is_int($aVal) || is_int($bVal)) { |
|
30 | + if (is_int($aVal) || is_int($bVal)) { |
|
31 | 31 | return $this->compareInts($aVal, $bVal); |
32 | 32 | } |
33 | 33 | return 0; |
@@ -11,8 +11,8 @@ |
||
11 | 11 | public function format($items) |
12 | 12 | { |
13 | 13 | $newItems = []; |
14 | - foreach($items as $item) { |
|
15 | - foreach($item->original()->users() as $user) { |
|
14 | + foreach ($items as $item) { |
|
15 | + foreach ($item->original()->users() as $user) { |
|
16 | 16 | $newItem = clone $item; |
17 | 17 | $dataUser = $user->data(); |
18 | 18 | $newItem->addRow('User ID', $user->id()); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | protected function config(string $key, $default = null) |
64 | 64 | { |
65 | - if(array_key_exists($key, $this->config)) { |
|
65 | + if (array_key_exists($key, $this->config)) { |
|
66 | 66 | return $this->config[$key]; |
67 | 67 | } |
68 | 68 | return $default; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | protected function canHandle(FormattedItem $item): bool |
87 | 87 | { |
88 | - if($this->handles() === self::ALL) { |
|
88 | + if ($this->handles() === self::ALL) { |
|
89 | 89 | return true; |
90 | 90 | } |
91 | 91 | return $item->isType($this->handles()); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | protected function prepareItems($items) |
29 | 29 | { |
30 | 30 | $formattedItems = []; |
31 | - foreach($items as $item) { |
|
31 | + foreach ($items as $item) { |
|
32 | 32 | $formattedItems[] = FormattedItem::create($item); |
33 | 33 | } |
34 | 34 | return $formattedItems; |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | |
37 | 37 | public function export($items = []) |
38 | 38 | { |
39 | - if($items instanceof Collection) { |
|
39 | + if ($items instanceof Collection) { |
|
40 | 40 | $items = $items->all(); |
41 | 41 | } |
42 | 42 | $formattedItems = $this->prepareItems($items); |
43 | - foreach($this->getFormatters() as $formatter) { |
|
44 | - $time=-hrtime(true); |
|
43 | + foreach ($this->getFormatters() as $formatter) { |
|
44 | + $time = -hrtime(true); |
|
45 | 45 | $formattedItems = $formatter->format($formattedItems); |
46 | - $time+=hrtime(true); |
|
46 | + $time += hrtime(true); |
|
47 | 47 | $this->logTime(class_basename($formatter), $time / 1e+9); |
48 | 48 | } |
49 | 49 | $this->save($formattedItems); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | protected function getFormatters() |
56 | 56 | { |
57 | 57 | return array_map(function($className) { |
58 | - if(class_exists($className)) { |
|
58 | + if (class_exists($className)) { |
|
59 | 59 | return new $className($this->config('formatters')[$className]); |
60 | 60 | } |
61 | 61 | throw new \Exception(sprintf('Formatter %s does not exist', $className)); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | protected function config(string $key, $default = null) |
78 | 78 | { |
79 | - if(array_key_exists($key, $this->config)) { |
|
79 | + if (array_key_exists($key, $this->config)) { |
|
80 | 80 | return $this->config[$key]; |
81 | 81 | } |
82 | 82 | return $default; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | private function logTime(string $formatter, float $time) |
86 | 86 | { |
87 | - if(config('control.log-formatters')) { |
|
87 | + if (config('control.log-formatters')) { |
|
88 | 88 | Log::info(sprintf('Formatter [%s] took %.2f s to run', $formatter, $time)); |
89 | 89 | } |
90 | 90 | } |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | */ |
157 | 157 | protected function registerConfig() |
158 | 158 | { |
159 | - $this->publishes([__DIR__ .'/../config/control.php' => config_path('control.php'), |
|
159 | + $this->publishes([__DIR__.'/../config/control.php' => config_path('control.php'), |
|
160 | 160 | ], 'config'); |
161 | 161 | $this->mergeConfigFrom( |
162 | - __DIR__ .'/../config/control.php', 'control' |
|
162 | + __DIR__.'/../config/control.php', 'control' |
|
163 | 163 | ); |
164 | 164 | } |
165 | 165 | |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | public function registerFactories() |
172 | 172 | { |
173 | 173 | if (!app()->environment('production') && class_exists(\Faker\Factory::class)) { |
174 | - $this->app->make(Factory::class)->load(__DIR__ .'/../database/factories'); |
|
174 | + $this->app->make(Factory::class)->load(__DIR__.'/../database/factories'); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | 178 | public function registerMigrations() |
179 | 179 | { |
180 | - $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
|
180 | + $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | public function bindContracts() |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | Route::prefix(config('control.api_prefix')) |
306 | 306 | ->middleware(config('control.api_middleware')) |
307 | 307 | ->namespace('BristolSU\ControlDB\Http\Controllers') |
308 | - ->group(__DIR__ . '/../routes/api.php'); |
|
308 | + ->group(__DIR__.'/../routes/api.php'); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | private function setupObservers() |
@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | public function getById(int $id): \BristolSU\ControlDB\Contracts\Models\DataGroup |
34 | 34 | { |
35 | - return $this->cache->rememberForever(static::class . '@getById:' . $id, function() use ($id) { |
|
35 | + return $this->cache->rememberForever(static::class.'@getById:'.$id, function() use ($id) { |
|
36 | 36 | return $this->dataGroupRepository->getById($id); |
37 | 37 | }); |
38 | 38 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function getTagByFullReference(string $reference): \BristolSU\ControlDB\Contracts\Models\Tags\RoleTag |
46 | 46 | { |
47 | - return $this->cache->rememberForever(static::class . '@getTagByFullReference:' . $reference, function() use ($reference) { |
|
47 | + return $this->cache->rememberForever(static::class.'@getTagByFullReference:'.$reference, function() use ($reference) { |
|
48 | 48 | return $this->roleTagRepository->getTagByFullReference($reference); |
49 | 49 | }); |
50 | 50 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function getById(int $id): \BristolSU\ControlDB\Contracts\Models\Tags\RoleTag |
59 | 59 | { |
60 | - return $this->cache->rememberForever(static::class . '@getById:' . $id, function() use ($id) { |
|
60 | + return $this->cache->rememberForever(static::class.'@getById:'.$id, function() use ($id) { |
|
61 | 61 | return $this->roleTagRepository->getById($id); |
62 | 62 | }); |
63 | 63 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function allThroughTagCategory(\BristolSU\ControlDB\Contracts\Models\Tags\RoleTagCategory $roleTagCategory): Collection |
96 | 96 | { |
97 | - return $this->cache->rememberForever(static::class . '@allThroughTagCategory:' . $roleTagCategory->id(), function() use ($roleTagCategory) { |
|
97 | + return $this->cache->rememberForever(static::class.'@allThroughTagCategory:'.$roleTagCategory->id(), function() use ($roleTagCategory) { |
|
98 | 98 | return $this->roleTagRepository->allThroughTagCategory($roleTagCategory); |
99 | 99 | }); |
100 | 100 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function getTagByFullReference(string $reference): \BristolSU\ControlDB\Contracts\Models\Tags\GroupTag |
46 | 46 | { |
47 | - return $this->cache->rememberForever(static::class . '@getTagByFullReference:' . $reference, function() use ($reference) { |
|
47 | + return $this->cache->rememberForever(static::class.'@getTagByFullReference:'.$reference, function() use ($reference) { |
|
48 | 48 | return $this->groupTagRepository->getTagByFullReference($reference); |
49 | 49 | }); |
50 | 50 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function getById(int $id): \BristolSU\ControlDB\Contracts\Models\Tags\GroupTag |
59 | 59 | { |
60 | - return $this->cache->rememberForever(static::class . '@getById:' . $id, function() use ($id) { |
|
60 | + return $this->cache->rememberForever(static::class.'@getById:'.$id, function() use ($id) { |
|
61 | 61 | return $this->groupTagRepository->getById($id); |
62 | 62 | }); |
63 | 63 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function allThroughTagCategory(\BristolSU\ControlDB\Contracts\Models\Tags\GroupTagCategory $groupTagCategory): Collection |
96 | 96 | { |
97 | - return $this->cache->rememberForever(static::class . '@allThroughTagCategory:' . $groupTagCategory->id(), function() use ($groupTagCategory) { |
|
97 | + return $this->cache->rememberForever(static::class.'@allThroughTagCategory:'.$groupTagCategory->id(), function() use ($groupTagCategory) { |
|
98 | 98 | return $this->groupTagRepository->allThroughTagCategory($groupTagCategory); |
99 | 99 | }); |
100 | 100 | } |