@@ -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 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | }; |
91 | 91 | $localValue = call_user_func($conv, $formattedLocalRow); |
92 | 92 | $foreignValue = call_user_func($conv, $formattedForeignRow); |
93 | - if(json_encode($localValue) !== json_encode($foreignValue)) { |
|
93 | + if (json_encode($localValue) !== json_encode($foreignValue)) { |
|
94 | 94 | $diff[$key] = ['local' => $localValue, 'foreign' => $foreignValue]; |
95 | 95 | } |
96 | 96 | } |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getDiffFormatted(array $fields = null, $format = null) { |
107 | 107 | $diff = $this->getDiff($fields); |
108 | - if($format === null) { |
|
108 | + if ($format === null) { |
|
109 | 109 | $result = []; |
110 | - $formatVal = function ($value) { |
|
110 | + $formatVal = function($value) { |
|
111 | 111 | $value = preg_replace('/\\s+/', ' ', $value); |
112 | - if(strlen($value) > 20) { |
|
113 | - $value = substr($value, 0, 16) . ' ...'; |
|
112 | + if (strlen($value) > 20) { |
|
113 | + $value = substr($value, 0, 16).' ...'; |
|
114 | 114 | } |
115 | 115 | return $value; |
116 | 116 | }; |
117 | - foreach($diff as $fieldName => $values) { |
|
117 | + foreach ($diff as $fieldName => $values) { |
|
118 | 118 | $foreignValue = $formatVal($values['foreign']); |
119 | 119 | $localValue = $formatVal($values['local']); |
120 | 120 | $result[] = sprintf("%s: %s -> %s", $fieldName, $foreignValue, $localValue); |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | * @return array |
131 | 131 | */ |
132 | 132 | private function applyOptions(array $row, array $options) { |
133 | - if(count($options) < 1) { |
|
133 | + if (count($options) < 1) { |
|
134 | 134 | return $row; |
135 | 135 | } |
136 | - if(array_key_exists('keys', $options) && is_array($options['keys'])) { |
|
136 | + if (array_key_exists('keys', $options) && is_array($options['keys'])) { |
|
137 | 137 | $row = array_intersect_key($row, array_combine($options['keys'], $options['keys'])); |
138 | 138 | } |
139 | - if(array_key_exists('ignore', $options) && is_array($options['ignore'])) { |
|
139 | + if (array_key_exists('ignore', $options) && is_array($options['ignore'])) { |
|
140 | 140 | $row = array_diff_key($row, array_combine($options['ignore'], $options['ignore'])); |
141 | 141 | } |
142 | 142 | return $row; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | private function formatRow($row) { |
150 | 150 | $schema = $this->converter; |
151 | - $schema = array_map(function () { return null; }, $schema); |
|
151 | + $schema = array_map(function() { return null; }, $schema); |
|
152 | 152 | $row = array_merge($schema, $row); |
153 | 153 | return $row; |
154 | 154 | } |