decrement() публичный Метод

Decrements a field by the specified value. Works identically to increment(), but in reverse.
См. также: lithium\data\Entity::increment()
public decrement ( string $field, string $value = 1 ) : integer
$field string The name of the field to decrement.
$value string The value by which to decrement the field. Defaults to `1`.
Результат integer Returns the new value of `$field`, after modification.
Пример #1
0
 public function testIncrement()
 {
     $entity = new Entity(array('data' => array('counter' => 0)));
     $this->assertEqual(0, $entity->counter);
     $entity->increment('counter');
     $this->assertEqual(1, $entity->counter);
     $entity->decrement('counter', 5);
     $this->assertEqual(-4, $entity->counter);
     $this->assertNull($entity->increment);
     $entity->increment('foo');
     $this->assertEqual(1, $entity->foo);
     $this->assertFalse(isset($entity->bar));
     $entity->bar = 'blah';
     $entity->sync();
     $this->expectException("/^Field 'bar' cannot be incremented.\$/");
     $entity->increment('bar');
 }