public addAttribute ( string $attributeName, string $attributeType ) : |
||
$attributeName | string | the attribute name |
$attributeType | string | the attribute type |
Résultat |
public function addAttribute($attributeName, $attributeType)
{
if (empty($attributeName) || empty($attributeType)) {
throw new \InvalidArgumentException(sprintf('Attribute name "%s" and/or attribute type "%s" is invalid for Struct "%s"', $attributeName, $attributeType, $this->getName()), __LINE__);
}
if ($this->attributes->getStructAttributeByName($attributeName) === null) {
$structAttribute = new StructAttribute($this->getGenerator(), $attributeName, $attributeType, $this);
$this->attributes->add($structAttribute);
}
return $this;
}
/** * @expectedException \InvalidArgumentException */ public function testSetModelBasNameOneAttributeWithException() { $struct = new StructModel(self::bingGeneratorInstance(), 'Foo'); $struct->addAttribute('bar', 'string'); $array = new ArrayFile(self::bingGeneratorInstance(), 'Foo'); $array->setModel($struct); }