/** * Set the attribute value (and infer the type automatically). * * @param $value */ public function setValue($values) { if (!is_array($values)) { $values = [$values]; } if (count($values) === 0 || is_null(reset($values))) { return; } $this->type = Xml::attributeType(reset($values)); $this->value = []; foreach ($values as $value) { if ('DATE' === $this->type && !Date::isEmpty($value)) { $value = Date::format($value); } $this->value[] = $value; } }
/** * Set the attribute value (and infer the type automatically). * * @param $value */ public function setValue($value) { $type = Xml::attributeType($value); if ('DATE' === $type && !Date::isEmpty($value)) { $value = Date::format($value); } $this->value = $value; $this->type = $type; }
public function testXmlAttributeTypeString() { $this->assertEquals(Xml::attributeType('foobar'), 'STRING'); }