Chris@0: name = $name; Chris@0: $this->value = $value; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns a string representation of the attribute. Chris@0: * Chris@0: * While __toString only returns the value in a string form, render() Chris@0: * contains the name of the attribute as well. Chris@0: * Chris@0: * @return string Chris@0: * The string representation of the attribute. Chris@0: */ Chris@0: public function render() { Chris@0: $value = (string) $this; Chris@0: if (isset($this->value) && static::RENDER_EMPTY_ATTRIBUTE || !empty($value)) { Chris@0: return Html::escape($this->name) . '="' . $value . '"'; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the raw value. Chris@0: */ Chris@0: public function value() { Chris@0: return $this->value; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements the magic __toString() method. Chris@0: */ Chris@0: abstract public function __toString(); Chris@0: Chris@0: }