/** * Adds a new Composition at CompositionCollection. * * @param string $composition * * @return bool */ public function add($composition) { if (!$this->contains($composition)) { parent::add($composition); } return true; }
/** * Adds a new Use on the collection. * * @param UseInterface $use * * @throws \InvalidArgumentException * @return bool */ public function add($use) { if (!$use instanceof UseInterface) { throw new \InvalidArgumentException('This Property must be a instance of \\ClassGeneration\\UseInterface'); } return parent::add($use); }
/** * Adds a new Tag on Dockblock. * * @param TagInterface $tag * * @throws \InvalidArgumentException * @return bool */ public function add($tag) { if (!$tag instanceof TagInterface) { throw new \InvalidArgumentException('This tag is not allowed'); } if ($this->isUniqueTag($tag->getName())) { $this->removeByName($tag->getName()); } return parent::add($tag); }
/** * Adds a new Constant at ConstantCollection. * * @param ConstantInterface $constant * * @throws \InvalidArgumentException * @return bool */ public function add($constant) { if (!$constant instanceof ConstantInterface) { throw new \InvalidArgumentException('This Constant must be a instance of \\ClassGeneration\\ConstantInterface'); } if ($constant->getName() === null) { $constant->setName('constant' . ($this->count() + 1)); } return parent::add($constant); }
public function testIsEmptyInArrayCollection() { $collection = new ArrayCollection(); $this->assertTrue($collection->isEmpty()); $collection->add('element'); $this->assertFalse($collection->isEmpty()); }