/** * 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); }
/** * @inheritdoc */ public function addConstant(ConstantInterface $const) { $const->setParent($this); $this->getConstantCollection()->add($const); return $this; }