1 | <?php |
||
13 | class Write implements PipeInterface |
||
14 | { |
||
15 | use IdentificationTrait; |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $identifier; |
||
20 | /** |
||
21 | * @var Connection |
||
22 | */ |
||
23 | private $connection; |
||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $table; |
||
28 | /** |
||
29 | * @var AutoIncrementCallbackInterface|null |
||
30 | */ |
||
31 | private $callback; |
||
32 | /** |
||
33 | * @var WriterUtilityInterface |
||
34 | */ |
||
35 | private $utility; |
||
36 | /** |
||
37 | * @var UpdateStrategyInterface |
||
38 | */ |
||
39 | private $updateStrategy; |
||
40 | /** |
||
41 | * @var EmitterInterface |
||
42 | */ |
||
43 | private $emitter; |
||
44 | /** |
||
45 | * @var string|null |
||
46 | */ |
||
47 | private $autoIncrementColumn; |
||
48 | |||
49 | 6 | public function __construct( |
|
66 | |||
67 | /** |
||
68 | * DBAL Insert statement. |
||
69 | * Inserts data into a table using DBAL. |
||
70 | * |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | 5 | public function pass(DataBagInterface $dataBag): DataBagInterface |
|
84 | |||
85 | 4 | private function insertRecord(array $dataToInsert, DataBagInterface $dataBag) |
|
95 | |||
96 | /** |
||
97 | * @param array $dataToInsert |
||
98 | * @param DataBagInterface $dataBag |
||
99 | * @throws DBALException |
||
100 | */ |
||
101 | 2 | private function updateRecord(array $dataToInsert, DataBagInterface $dataBag) |
|
117 | |||
118 | 5 | private function getDataToInsert(DataBagInterface $dataBag): array |
|
133 | |||
134 | /** |
||
135 | * @return null|string |
||
136 | */ |
||
137 | 4 | private function getAutoIncrementColumn(): ?string |
|
150 | |||
151 | /** |
||
152 | * Get auto-increment field value of the record using given id. |
||
153 | * |
||
154 | * @param array $identifier |
||
155 | * @param string $autoIncrementColumn |
||
156 | * @return int |
||
157 | * @throws DBALException |
||
158 | */ |
||
159 | 1 | public function getRecordId(array $identifier, string $autoIncrementColumn): int |
|
175 | |||
176 | /** |
||
177 | * Checks if record already exists in the DB. |
||
178 | * |
||
179 | * @param DataBagInterface $dataBag |
||
180 | * @return bool |
||
181 | * @throws DBALException |
||
182 | */ |
||
183 | 5 | private function recordExists(DataBagInterface $dataBag): bool |
|
207 | } |
||
208 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: