/** * @param MethodInterface $method * @return bool */ public function add($method) { if (!$method instanceof MethodInterface) { throw new \InvalidArgumentException('This Method must be a instance of \\ClassGeneration\\Composition\\MethodInterface'); } parent::set($method->getTraitName() . '.' . $method->getName(), $method); return true; }
/** * Adds a new Method on collection. * * @param MethodInterface $method * * @return bool * * @throws \InvalidArgumentException */ public function add($method) { if (!$method instanceof MethodInterface) { throw new \InvalidArgumentException('This Method must be a instance of \\ClassGeneration\\MethodInterface'); } if ($method->getName() === null) { $method->setName('method' . ($this->count() + 1)); } parent::set($method->getName(), $method); return true; }
/** * Adds a new Property on the collection. * * @param PropertyInterface $property * * @return bool * @throws \InvalidArgumentException */ public function add($property) { if (!$property instanceof PropertyInterface) { throw new \InvalidArgumentException('This Property must be a instance of \\ClassGeneration\\PropertyInterface'); } if ($property->getName() === null) { $property->setName('property' . ($this->count() + 1)); } parent::set($property->getName(), $property); return true; }
public function testSetInArrayCollection() { $collection = new ArrayCollection(array('element', 'last')); $collection->set(0, 'first'); $this->assertEquals('first', $collection->first()); }