| Conditions | 4 |
| Paths | 6 |
| Total Lines | 25 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function save(TransactionInterface $transaction = null, bool $queueRelations = true): int |
||
| 19 | { |
||
| 20 | //Initial reacord command |
||
| 21 | $command = $this->queueSave(false); |
||
| 22 | |||
| 23 | if ($command instanceof InsertCommand) { |
||
| 24 | $state = self::CREATED; |
||
| 25 | } elseif ($command instanceof UpdateCommand) { |
||
| 26 | $state = self::UPDATED; |
||
| 27 | } else { |
||
| 28 | $state = self::UNCHANGED; |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($queueRelations) { |
||
| 32 | //Mounting relation related updates |
||
| 33 | $command = $this->relations->queueRelations($command); |
||
| 34 | } |
||
| 35 | |||
| 36 | //todo: saturate command |
||
| 37 | |||
| 38 | //Registering command |
||
| 39 | $transaction->addCommand($command); |
||
|
|
|||
| 40 | |||
| 41 | return $state; |
||
| 42 | } |
||
| 43 | |||
| 51 | } |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: