Пример #1
0
 /**
  * @param string $name
  * @param string $value
  */
 public function setAttribute($name, $value)
 {
     $attribute = $this->getAttribute($name);
     if (!$attribute) {
         $this->attributes->append(new Attribute($name, $value, Attribute::QUOTE_DOUBLE));
     } else {
         $attribute->setValue($value);
     }
 }
Пример #2
0
 /**
  * @param string $type
  * @return Collection|Attribute[]
  */
 public function getAttributesByType($type)
 {
     return $this->attributes->filter(function ($attribute) use($type) {
         /** @var Attribute $attribute */
         return $attribute->getType() == $type;
     });
 }