/** * @return StructAttributeContainer */ public static function instance() { $struct = StructTest::instance('Bar', true); $structAttributeContainer = new StructAttributeContainer(self::getBingGeneratorInstance()); $structAttributeContainer->add(new StructAttribute(self::getBingGeneratorInstance(), 'foo', 'string', $struct)); $structAttributeContainer->add(new StructAttribute(self::getBingGeneratorInstance(), 'bar', 'int', $struct)); $structAttributeContainer->add(new StructAttribute(self::getBingGeneratorInstance(), 'Bar', 'float', $struct)); $structAttributeContainer->add(new StructAttribute(self::getBingGeneratorInstance(), 'fooBar', 'bool', $struct)); return $structAttributeContainer; }
/** * Adds attribute based on its original name * @throws \InvalidArgumentException * @param string $attributeName the attribute name * @param string $attributeType the attribute type * @return Struct */ 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; }