| Conditions | 3 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3.1825 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 3 | public function lastInsertId(?string $name = null) : string |
|
| 20 | { |
||
| 21 | 3 | if ($name === null) { |
|
| 22 | 2 | return parent::lastInsertId($name); |
|
| 23 | } |
||
| 24 | |||
| 25 | 1 | $stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?'); |
|
| 26 | 1 | $stmt->execute([$name]); |
|
| 27 | |||
| 28 | 1 | $result = $stmt->fetchColumn(); |
|
| 29 | |||
| 30 | 1 | if ($result === false) { |
|
| 31 | // WIP regarding exceptions, see: |
||
| 32 | // https://github.com/doctrine/dbal/pull/3335#discussion_r234381175 |
||
| 33 | throw new class ('No sequence with name "' . $name . '" found.') extends AbstractDriverException { |
||
| 34 | }; |
||
| 35 | } |
||
| 36 | |||
| 37 | 1 | return (string) $result; |
|
| 38 | } |
||
| 63 |