| Total Complexity | 5 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 92.86% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class Increment extends Literal { |
||
| 16 | /** |
||
| 17 | * @var int The amount to increment. |
||
| 18 | */ |
||
| 19 | private $inc; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Construct an increment. |
||
| 23 | * |
||
| 24 | * @param int $inc The amount to increment by. |
||
| 25 | */ |
||
| 26 | 2 | public function __construct($inc = 1) { |
|
| 27 | 2 | parent::__construct('%1$s %2$+d'); |
|
| 28 | 2 | $this->setInc($inc); |
|
| 29 | 2 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * {@inheritdoc} |
||
| 33 | */ |
||
| 34 | 2 | public function getValue(Db $db, ...$args) { |
|
| 35 | 2 | if (empty($args)) { |
|
| 36 | throw new \InvalidArgumentException("Increment must specify the column to increment."); |
||
| 37 | } |
||
| 38 | |||
| 39 | 2 | $args[1] = $this->getInc(); |
|
| 40 | 2 | return parent::getValue($db, ...$args); |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Get the amount to increment. |
||
| 45 | * |
||
| 46 | * @return int Returns a number. |
||
| 47 | */ |
||
| 48 | 2 | public function getInc() { |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Set the amount to increment. |
||
| 54 | * |
||
| 55 | * @param int $inc |
||
| 56 | * @return $this |
||
| 57 | */ |
||
| 58 | 2 | public function setInc($inc) { |
|
| 61 | } |
||
| 62 | } |
||
| 63 |