Lines Matching refs:attribute

24      * Add a value to an attribute.
29 * Delete a value, or values, from an attribute.
34 * Replaces the current value of an attribute with a different one.
46 protected $attribute;
50 * @param string|Attribute $attribute
53 public function __construct(int $modType, $attribute, ...$values)
56 $this->attribute = $attribute instanceof Attribute ? $attribute : new Attribute($attribute, ...$values);
64 return $this->attribute;
68 * @param Attribute $attribute
71 public function setAttribute(Attribute $attribute)
73 $this->attribute = $attribute;
110 return $this->modType === self::TYPE_DELETE && count($this->attribute->getValues()) !== 0;
126 return $this->modType === self::TYPE_DELETE && count($this->attribute->getValues()) === 0;
130 * Add the values contained in the attribute, creating the attribute if necessary.
132 * @param string|Attribute $attribute
136 public static function add($attribute, ...$values): Change
138 $attribute = $attribute instanceof Attribute ? $attribute : new Attribute($attribute, ...$values);
140 return new self(self::TYPE_ADD, $attribute);
144 * Delete values from the attribute. If no values are listed, or if all current values of the attribute are listed,
145 * the entire attribute is removed.
147 * @param Attribute|string $attribute
151 public static function delete($attribute, ...$values): Change
153 $attribute = $attribute instanceof Attribute ? $attribute : new Attribute($attribute, ...$values);
155 return new self(self::TYPE_DELETE, $attribute);
159 * Replace all existing values with the new values, creating the attribute if it did not already exist. A replace
160 * with no value will delete the entire attribute if it exists, and it is ignored if the attribute does not exist.
162 * @param Attribute|string $attribute
166 public static function replace($attribute, ...$values): Change
168 $attribute = $attribute instanceof Attribute ? $attribute : new Attribute($attribute, ...$values);
170 return new self(self::TYPE_REPLACE, $attribute);
174 * Remove all values from an attribute, essentially un-setting/resetting it. This is the same type as delete when
177 * @param string|Attribute $attribute
180 public static function reset($attribute): Change
182 $attribute = $attribute instanceof Attribute ? new Attribute($attribute->getDescription()) : new Attribute($attribute);
184 return new self(self::TYPE_DELETE, $attribute);