| Total Complexity | 7 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class Statement extends PDOStatement { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var DB |
||
| 16 | */ |
||
| 17 | protected $db; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * PDO requires this to be protected. |
||
| 21 | * |
||
| 22 | * @param DB $db |
||
| 23 | */ |
||
| 24 | protected function __construct (DB $db) { |
||
| 25 | $this->db = $db; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Fluent execution. |
||
| 30 | * |
||
| 31 | * @param array $args |
||
| 32 | * @return $this |
||
| 33 | */ |
||
| 34 | public function __invoke (array $args = null) { |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * The query string. |
||
| 41 | * |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | public function __toString () { |
||
| 45 | return $this->queryString; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Logs. |
||
| 50 | * PHP returns `false` instead of throwing if too many arguments were given. |
||
| 51 | * This checks for that and throws. |
||
| 52 | * |
||
| 53 | * @param array $args |
||
| 54 | * @return bool |
||
| 55 | * @throws ArgumentCountError |
||
| 56 | */ |
||
| 57 | public function execute ($args = null) { |
||
| 58 | $this->db->getLogger()->__invoke($this->queryString); |
||
| 59 | if ($result = !parent::execute($args)) { |
||
| 60 | $info = $this->errorInfo(); |
||
| 61 | if ($info[0] == 0) { |
||
| 62 | $argc = count($args); |
||
| 63 | throw new ArgumentCountError("Too many arguments given ({$argc})"); |
||
| 64 | } |
||
| 65 | } |
||
| 66 | return $result; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * `lastInsertId()` |
||
| 71 | * |
||
| 72 | * @return int |
||
| 73 | */ |
||
| 74 | public function getId (): int { |
||
| 76 | } |
||
| 77 | } |
||
| 78 |