1 | <?php |
||
31 | class Attribute extends AbstractNamed implements AttributeInterface { |
||
32 | /** |
||
33 | * A hash of default values for allowed attributes. |
||
34 | * |
||
35 | * If it is empty, any attribute is allowed. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | public static $fDefaults = array(); |
||
40 | |||
41 | public $fValue; |
||
42 | |||
43 | /** |
||
44 | * @param \Pimple\Container $dic |
||
45 | * @param string $name |
||
46 | * @param mixed $value |
||
47 | * |
||
48 | * @see AttributeInterface::__construct() |
||
49 | */ |
||
50 | 49 | public function __construct(Container $dic, $name, $value = null) { |
|
55 | |||
56 | /** |
||
57 | * @todo FIXME escape name, value more carefully |
||
58 | * |
||
59 | * @param boolean $directed |
||
60 | * Needed for signature conformity,but actually ignored. |
||
61 | * |
||
62 | * @return null|string |
||
63 | */ |
||
64 | 38 | public function build($directed = null) { |
|
77 | |||
78 | /** |
||
79 | * @see AttributeInterface::getAllowedNames() |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | 1 | public static function getAllowedNames() { |
|
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | 1 | public static function getDefaultValue($name) { |
|
97 | |||
98 | 49 | public function getType() { |
|
102 | |||
103 | 41 | public function getValue() { |
|
106 | |||
107 | /** |
||
108 | * In addition to basic behavior, validate name. |
||
109 | * |
||
110 | * @see AbstractNamed::setName() |
||
111 | * |
||
112 | * @throws AttributeNameException |
||
113 | */ |
||
114 | 49 | public function setName($name) { |
|
122 | |||
123 | /** |
||
124 | * Note: a null default value will work too: if $value is not null, the |
||
125 | * default is ignored, and if value is null, isset() fails, and fValue is set |
||
126 | * to $value, i.e. null too. |
||
127 | * |
||
128 | * @see AttributeInterface::setValue() |
||
129 | */ |
||
130 | 49 | public function setValue($value = null) { |
|
138 | } |
||
139 |