attributes[] = $attribute; } /** * Get attributes * * @return Attribute[] * * @since 1.0.0 */ public function getAttributes() : array { return $this->attributes; } /** * Has attribute value * * @param string $attrName Attribute name * @param mixed $attrValue Attribute value * * @return bool * * @since 1.0.0 */ public function hasAttributeValue(string $attrName, mixed $attrValue) : bool { foreach ($this->attributes as $attribute) { if ($attribute->type->name === $attrName && $attribute->value->getValue() === $attrValue) { return true; } } return false; } /** * Check if a certain attribute type exists by name * * @param string $attrName Attribute name to check * * @return bool * * @since 1.0.0 */ public function hasAttributeType(string $attrName) : bool { foreach ($this->attributes as $attribute) { if ($attribute->type->name === $attrName && !empty($attribute->value->getValue())) { return true; } } return false; } /** * Get attribute * * @param string $attrName Attribute name * * @return Attribute * * @since 1.0.0 */ public function getAttribute(string $attrName) : Attribute { foreach ($this->attributes as $attribute) { if ($attribute->type->name === $attrName) { return $attribute; } } return new NullAttribute(); } }