@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | $keys = array_keys(array_merge($this->row, $this->foreignRow)); |
78 | 78 | $formattedLocalRow = $this->formatRow($localRow); |
79 | 79 | $formattedForeignRow = $this->formatRow($foreignRow); |
80 | - foreach($keys as $key) { |
|
81 | - $conv = function (array $row) use ($key) { |
|
80 | + foreach ($keys as $key) { |
|
81 | + $conv = function(array $row) use ($key) { |
|
82 | 82 | $value = null; |
83 | - if(array_key_exists($key, $row)) { |
|
83 | + if (array_key_exists($key, $row)) { |
|
84 | 84 | $value = $row[$key]; |
85 | - if(array_key_exists($key, $this->converter) && $value !== null) { |
|
85 | + if (array_key_exists($key, $this->converter) && $value !== null) { |
|
86 | 86 | $value = call_user_func($this->converter[$key], $value); |
87 | 87 | } |
88 | 88 | } |
@@ -91,15 +91,15 @@ discard block |
||
91 | 91 | $localValue = call_user_func($conv, $formattedLocalRow); |
92 | 92 | $foreignValue = call_user_func($conv, $formattedForeignRow); |
93 | 93 | |
94 | - if(is_scalar($localValue)) { |
|
94 | + if (is_scalar($localValue)) { |
|
95 | 95 | $localValue = (string) $localValue; |
96 | 96 | } |
97 | 97 | |
98 | - if(is_scalar($foreignValue)) { |
|
98 | + if (is_scalar($foreignValue)) { |
|
99 | 99 | $foreignValue = (string) $foreignValue; |
100 | 100 | } |
101 | 101 | |
102 | - if(json_encode($localValue) !== json_encode($foreignValue)) { |
|
102 | + if (json_encode($localValue) !== json_encode($foreignValue)) { |
|
103 | 103 | $diff[$key] = ['local' => $localValue, 'foreign' => $foreignValue]; |
104 | 104 | } |
105 | 105 | } |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function getDiffFormatted(array $fields = null, $format = null) { |
116 | 116 | $diff = $this->getDiff($fields); |
117 | - if($format === null) { |
|
117 | + if ($format === null) { |
|
118 | 118 | $result = []; |
119 | - $formatVal = function ($value) { |
|
119 | + $formatVal = function($value) { |
|
120 | 120 | $value = preg_replace('/\\s+/', ' ', $value); |
121 | - if(strlen($value) > 20) { |
|
122 | - $value = substr($value, 0, 16) . ' ...'; |
|
121 | + if (strlen($value) > 20) { |
|
122 | + $value = substr($value, 0, 16).' ...'; |
|
123 | 123 | } |
124 | 124 | return $value; |
125 | 125 | }; |
126 | - foreach($diff as $fieldName => $values) { |
|
126 | + foreach ($diff as $fieldName => $values) { |
|
127 | 127 | $foreignValue = $formatVal($values['foreign']); |
128 | 128 | $localValue = $formatVal($values['local']); |
129 | 129 | $result[] = sprintf("%s: %s -> %s", $fieldName, $foreignValue, $localValue); |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | * @return array |
140 | 140 | */ |
141 | 141 | private function applyOptions(array $row, array $options) { |
142 | - if(count($options) < 1) { |
|
142 | + if (count($options) < 1) { |
|
143 | 143 | return $row; |
144 | 144 | } |
145 | - if(array_key_exists('keys', $options) && is_array($options['keys'])) { |
|
145 | + if (array_key_exists('keys', $options) && is_array($options['keys'])) { |
|
146 | 146 | $row = array_intersect_key($row, array_combine($options['keys'], $options['keys'])); |
147 | 147 | } |
148 | - if(array_key_exists('ignore', $options) && is_array($options['ignore'])) { |
|
148 | + if (array_key_exists('ignore', $options) && is_array($options['ignore'])) { |
|
149 | 149 | $row = array_diff_key($row, array_combine($options['ignore'], $options['ignore'])); |
150 | 150 | } |
151 | 151 | return $row; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | private function formatRow($row) { |
159 | 159 | $schema = $this->converter; |
160 | - $schema = array_map(function () { return null; }, $schema); |
|
160 | + $schema = array_map(function() { return null; }, $schema); |
|
161 | 161 | $row = array_merge($schema, $row); |
162 | 162 | return $row; |
163 | 163 | } |