/** * Append an entity to the collection. * * @param EntityInterface $entity * @throws Exception\InvalidEntityException */ public function append(EntityInterface $entity) { if (!$this->isAllowed($entity)) { throw new Exception\InvalidEntityException(sprintf("Invalid entity '%s' for collection '%s'", get_class($entity), get_class($this))); } $this->entities->append($entity); }
public function testAppend() { $ar = new ArrayObject(array('one', 'two')); $this->assertEquals(2, $ar->count()); $ar->append('three'); $this->assertSame('three', $ar[2]); $this->assertEquals(3, $ar->count()); }
/** * Add constant to list * * @param string $constant * * @return $this */ public function addConstant($constant) { $this->constants->append($constant); return $this; }
/** * Only allow Vector2D objects to be appended * * @param \Chippyash\Matrix\Vector\Vector2D $value * @return \Chippyash\Matrix\Vector\VectorSet $this * @throws \Chippyash\Matrix\Exceptions\VectorException */ public function append($value) { if (!$value instanceof Vector2D) { throw new VectorException('Append value is not a vector'); } parent::append($value); return $this; }
/** * {@inheritdoc} * @throws Exception\InvalidArgumentException */ public function append($value) { $this->validateValue($value); return parent::append($value); }