friendship ended with social-app. php is my new best friend
1<?php 2 3/* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Symfony\Component\DomCrawler\Field; 13 14/** 15 * InputFormField represents an input form field (an HTML input tag). 16 * 17 * For inputs with type of file, checkbox, or radio, there are other more 18 * specialized classes (cf. FileFormField and ChoiceFormField). 19 * 20 * @author Fabien Potencier <fabien@symfony.com> 21 */ 22class InputFormField extends FormField 23{ 24 /** 25 * Initializes the form field. 26 * 27 * @throws \LogicException When node type is incorrect 28 */ 29 protected function initialize(): void 30 { 31 if ('input' !== $this->node->nodeName && 'button' !== $this->node->nodeName) { 32 throw new \LogicException(\sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName)); 33 } 34 35 $type = strtolower($this->node->getAttribute('type')); 36 if ('checkbox' === $type) { 37 throw new \LogicException('Checkboxes should be instances of ChoiceFormField.'); 38 } 39 40 if ('file' === $type) { 41 throw new \LogicException('File inputs should be instances of FileFormField.'); 42 } 43 44 $this->value = $this->node->getAttribute('value'); 45 } 46}