| Total Complexity | 4 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 20% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | trait FetchModeTrait { |
||
| 13 | /** |
||
| 14 | * @var array The fetch arguments (if any). |
||
| 15 | */ |
||
| 16 | private $fetchArgs = [PDO::FETCH_ASSOC]; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Get the default fetch mode. |
||
| 20 | * |
||
| 21 | * @return int Returns the current fetch mode. |
||
| 22 | */ |
||
| 23 | public function getFetchMode() { |
||
| 24 | return reset($this->fetchArgs); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Get the fetch arguments. |
||
| 29 | * |
||
| 30 | * @return array Returns an array of arguments including the fetch mode. |
||
| 31 | */ |
||
| 32 | 43 | public function getFetchArgs() { |
|
| 33 | 43 | return $this->fetchArgs; |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Set the default fetch mode. |
||
| 38 | * |
||
| 39 | * @param int|string $mode One of the **PDO::FETCH_*** constants or a class name. |
||
| 40 | * @param mixed ...$args Additional arguments for {@link \PDOStatement::fetchAll()}. |
||
| 41 | * @return $this |
||
| 42 | * @see http://php.net/manual/en/pdostatement.fetchall.php |
||
| 43 | */ |
||
| 44 | public function setFetchMode($mode, ...$args) { |
||
| 52 | } |
||
| 53 | } |
||
| 54 |