/** * @param Element $element * @return Select * @throws UnexpectedElementException */ public static function create(Element $element) { if (!$element->is('select')) { throw new UnexpectedElementException('Expected select element, got ' . $element->getTagName()); } return new Select($element); }
/** * @param Element $element * @return FileInput * @throws UnexpectedElementException */ public static function create(Element $element) { if (!$element->is('input')) { throw new UnexpectedElementException('Expected input element, got ' . $element->getTagName()); } $type = strtolower($element->getAttribute('type')); if ($type != 'file') { throw new UnexpectedElementException('Expected input type=file, got ' . $type); } return new FileInput($element); }
/** * @param Element $element * @return ToggleButton * @throws UnexpectedElementException */ public static function create(Element $element) { if (!$element->is('input')) { throw new UnexpectedElementException('Expected input element, got ' . $element->getTagName()); } switch ($type = $element->getAttribute('type')) { case 'checkbox': return new CheckBox($element); case 'radio': return new RadioButton($element); default: throw new UnexpectedElementException('Expected input type=checkbox|radiobutton, got ' . $type); } }