@@ -55,7 +55,7 @@ |
||
55 | 55 | |
56 | 56 | public function getItem($column, $default = null) |
57 | 57 | { |
58 | - if(array_key_exists($column, $this->prepared) && $this->prepared[$column] !== null) { |
|
58 | + if (array_key_exists($column, $this->prepared) && $this->prepared[$column] !== null) { |
|
59 | 59 | return $this->prepared[$column]; |
60 | 60 | } |
61 | 61 | return $default; |
@@ -52,7 +52,7 @@ |
||
52 | 52 | |
53 | 53 | private function exportData() |
54 | 54 | { |
55 | - switch($this->argument('type')) { |
|
55 | + switch ($this->argument('type')) { |
|
56 | 56 | case 'user': |
57 | 57 | return app(User::class)->all(); |
58 | 58 | break; |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | public function getHeaders($items) |
16 | 16 | { |
17 | 17 | $headers = []; |
18 | - foreach($items as $item) { |
|
19 | - foreach($item->getColumnNames() as $column) { |
|
20 | - if(!in_array($column, $headers)) { |
|
18 | + foreach ($items as $item) { |
|
19 | + foreach ($item->getColumnNames() as $column) { |
|
20 | + if (!in_array($column, $headers)) { |
|
21 | 21 | $headers[] = $column; |
22 | 22 | } |
23 | 23 | } |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | $headers = $headers ?? $this->getHeaders($items); |
37 | 37 | |
38 | 38 | $rows = []; |
39 | - foreach($items as $item) { |
|
39 | + foreach ($items as $item) { |
|
40 | 40 | $row = []; |
41 | - foreach($headers as $header) { |
|
41 | + foreach ($headers as $header) { |
|
42 | 42 | $row[] = $item->getItem($header, $defaultIfNull); |
43 | 43 | } |
44 | 44 | $rows[] = $row; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | fputcsv($csv, $this->getHeaders($items)); |
57 | 57 | |
58 | - foreach($this->getRows($items, $headers, $defaultIfNull) as $row) { |
|
58 | + foreach ($this->getRows($items, $headers, $defaultIfNull) as $row) { |
|
59 | 59 | fputcsv($csv, $row); |
60 | 60 | } |
61 | 61 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | protected function prepareItems($items) |
28 | 28 | { |
29 | 29 | $formattedItems = []; |
30 | - foreach($items as $item) { |
|
30 | + foreach ($items as $item) { |
|
31 | 31 | $formattedItems[] = FormattedItem::create($item); |
32 | 32 | } |
33 | 33 | return $formattedItems; |
@@ -35,11 +35,11 @@ discard block |
||
35 | 35 | |
36 | 36 | public function export($items = []) |
37 | 37 | { |
38 | - if($items instanceof Collection) { |
|
38 | + if ($items instanceof Collection) { |
|
39 | 39 | $items = $items->all(); |
40 | 40 | } |
41 | 41 | $formattedItems = $this->prepareItems($items); |
42 | - foreach($this->getFormatters() as $formatter) { |
|
42 | + foreach ($this->getFormatters() as $formatter) { |
|
43 | 43 | $formattedItems = $formatter->format($formattedItems); |
44 | 44 | } |
45 | 45 | $this->save($formattedItems); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | protected function getFormatters() |
52 | 52 | { |
53 | 53 | return array_map(function($className) { |
54 | - if(class_exists($className)) { |
|
54 | + if (class_exists($className)) { |
|
55 | 55 | return new $className($this->config('formatters')[$className]); |
56 | 56 | } |
57 | 57 | throw new \Exception(sprintf('Formatter %s does not exist', $className)); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | protected function config(string $key, $default = null) |
74 | 74 | { |
75 | - if(array_key_exists($key, $this->config)) { |
|
75 | + if (array_key_exists($key, $this->config)) { |
|
76 | 76 | return $this->config[$key]; |
77 | 77 | } |
78 | 78 | return $default; |
@@ -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()); |