set_name($name); $this->set_slug($slug); $this->value = $value; $this->standardize($type, $unit); } /** * Get the concrete value for the attribute. * * @since 0.8 * @return Value */ public function get_value() { return $this->value; } /** * Standardize the detail with the type and optional unit. * The unit will be stored only, if the type is number. * * @since 0.8 * @param Type $type The type like text or numeric * @param null|Unit $unit The optional unit like kg, cm or m². */ public function standardize(Type $type, Unit $unit = null) { $this->set_type($type); $this->set_unit($type->is_number() ? $unit : null); } /** * Check if the detail has an optional template ID. * * @since 0.8 * @return bool */ public function has_template_id() { return $this->template_id !== null; } /** * Get the optional detail template ID. * * @since 0.8 * @return null|Detail_Template_Id */ public function get_template_id() { return $this->template_id; } /** * Set the optional detail template ID. * * @since 0.8 * @param null|Detail_Template_Id $template_id */ public function set_template_id(Detail_Template_Id $template_id = null) { $this->template_id = $template_id; } /** * Check if this detail is equal to the other one. * * @since 0.6 * @param mixed $other * @return bool */ public function is_equal_to($other) { return $other instanceof self && $this->get_name()->is_equal_to($other->get_name()) && $this->get_slug()->is_equal_to($other->get_slug()) && $this->get_value()->is_equal_to($other->get_value()) && $this->get_type()->is_equal_to($other->get_type()) && ($this->has_unit() && $this->get_unit()->is_equal_to($other->get_unit()) || !$other->has_unit()) && ($this->has_template_id() && $this->get_template_id()->is_equal_to($other->get_template_id()) || !$other->has_template_id()); } }