for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Todd Burry <[email protected]>
* @copyright 2009-2017 Vanilla Forums Inc.
* @license MIT
*/
namespace Garden\Db;
* Represents an incrementer calculation.
*
* Pass an instance of this class as a value to a database update call.
class Increment extends Literal {
* @var int The amount to increment.
private $inc;
* Construct an increment.
* @param int $inc The amount to increment by.
public function __construct($inc = 1) {
parent::__construct('%1$s %2$+d');
$this->setInc($inc);
}
* {@inheritdoc}
public function getValue(Db $db, ...$args) {
if (empty($args)) {
throw new \InvalidArgumentException("Increment must specify the column to increment.");
$args[1] = $this->getInc();
return parent::getValue($db, ...$args);
* Get the amount to increment.
* @return int Returns a number.
public function getInc() {
return $this->inc;
* Set the amount to increment.
* @param int $inc
* @return $this
public function setInc($inc) {
$this->inc = (int)$inc;
return $this;