@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function addRow(array $data, array $translation = null, $duplicateKeyHandler = null) { |
66 | 66 | $data = $this->translate($data, $translation); |
67 | - if($duplicateKeyHandler === null) { |
|
67 | + if ($duplicateKeyHandler === null) { |
|
68 | 68 | $duplicateKeyHandler = $this->duplicateKeyHandler; |
69 | 69 | } |
70 | - $buildMetaData = function (array $data, array $keys) { |
|
70 | + $buildMetaData = function(array $data, array $keys) { |
|
71 | 71 | $metaData = $data; |
72 | 72 | $metaData = array_diff_key($metaData, array_diff_key($metaData, $keys)); |
73 | 73 | $metaData['___data'] = json_encode($data); |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | return $metaData; |
76 | 76 | }; |
77 | 77 | $metaData = $buildMetaData($data, $this->converter); |
78 | - if($duplicateKeyHandler === null) { |
|
78 | + if ($duplicateKeyHandler === null) { |
|
79 | 79 | $this->replaceStmt->execute($metaData); |
80 | 80 | } else { |
81 | 81 | try { |
82 | 82 | $this->insertStmt->execute($metaData); |
83 | 83 | } catch (\PDOException $e) { |
84 | - if(strpos($e->getMessage(), 'UNIQUE constraint failed') !== false) { |
|
84 | + if (strpos($e->getMessage(), 'UNIQUE constraint failed') !== false) { |
|
85 | 85 | $metaData = $buildMetaData($data, $this->converter); |
86 | 86 | unset($metaData['___data']); |
87 | 87 | unset($metaData['___sort']); |
88 | 88 | $this->selectStmt->execute($metaData); |
89 | 89 | $oldData = $this->selectStmt->fetch(PDO::FETCH_COLUMN, 0); |
90 | - if($oldData === null) { |
|
90 | + if ($oldData === null) { |
|
91 | 91 | $oldData = []; |
92 | 92 | } else { |
93 | 93 | $oldData = json_decode($oldData, true); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @return $this |
111 | 111 | */ |
112 | 112 | public function addRows($rows, array $translation = null, $duplicateKeyHandler = null) { |
113 | - foreach($rows as $row) { |
|
113 | + foreach ($rows as $row) { |
|
114 | 114 | $this->addRow($row, $translation, $duplicateKeyHandler); |
115 | 115 | } |
116 | 116 | return $this; |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function hasAnyChanges() { |
123 | 123 | /** @noinspection PhpUnusedLocalVariableInspection */ |
124 | - foreach($this->getNewOrChanged() as $_) { |
|
124 | + foreach ($this->getNewOrChanged() as $_) { |
|
125 | 125 | return true; |
126 | 126 | } |
127 | 127 | /** @noinspection PhpUnusedLocalVariableInspection */ |
128 | - foreach($this->getMissing() as $_) { |
|
128 | + foreach ($this->getMissing() as $_) { |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | return false; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | private function query($query) { |
242 | 242 | $stmt = $this->pdo->query($query); |
243 | 243 | $stmt->execute(['sA' => $this->storeA, 'sB' => $this->storeB]); |
244 | - while($row = $stmt->fetch(PDO::FETCH_NUM)) { |
|
244 | + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { |
|
245 | 245 | $d = json_decode($row[1], true); |
246 | 246 | $f = json_decode($row[2], true); |
247 | 247 | yield $this->instantiateRow($d, $f); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | '; |
266 | 266 | $stmt = $this->pdo->query($query); |
267 | 267 | $stmt->execute(['s' => $this->storeA]); |
268 | - while($row = $stmt->fetch(PDO::FETCH_NUM)) { |
|
268 | + while ($row = $stmt->fetch(PDO::FETCH_NUM)) { |
|
269 | 269 | $row = json_decode($row[0], true); |
270 | 270 | $row = $this->instantiateRow($row, []); |
271 | 271 | yield $row->getData(); |
@@ -279,10 +279,10 @@ discard block |
||
279 | 279 | * @return array |
280 | 280 | */ |
281 | 281 | private function translate(array $data, array $translation = null) { |
282 | - if($translation !== null) { |
|
282 | + if ($translation !== null) { |
|
283 | 283 | $result = []; |
284 | - foreach($data as $key => $value) { |
|
285 | - if(array_key_exists($key, $translation)) { |
|
284 | + foreach ($data as $key => $value) { |
|
285 | + if (array_key_exists($key, $translation)) { |
|
286 | 286 | $key = $translation[$key]; |
287 | 287 | } |
288 | 288 | $result[$key] = $value; |