| Total Complexity | 8 |
| Total Lines | 78 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class TextField extends FormField |
||
| 8 | { |
||
| 9 | protected $type = 'text'; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Get field value. |
||
| 13 | * |
||
| 14 | * @return mixed |
||
| 15 | */ |
||
| 16 | public function value() |
||
| 17 | { |
||
| 18 | if ($this->subtype() === 'password') { |
||
| 19 | return ''; |
||
| 20 | } |
||
| 21 | |||
| 22 | return parent::value(); |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Mark field as email. |
||
| 27 | * |
||
| 28 | * @return TextField |
||
| 29 | */ |
||
| 30 | public function asEmail() |
||
| 31 | { |
||
| 32 | return $this->withSubtype('email'); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Mark field as password. |
||
| 37 | * |
||
| 38 | * @return TextField |
||
| 39 | */ |
||
| 40 | public function asPassword() |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Mark field as phone. |
||
| 47 | * |
||
| 48 | * @return TextField |
||
| 49 | */ |
||
| 50 | public function asPhone() |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Mark field as phone. |
||
| 57 | * |
||
| 58 | * @return TextField |
||
| 59 | */ |
||
| 60 | public function asTel() |
||
| 61 | { |
||
| 62 | return $this->withSubtype('tel'); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Set field subtype. |
||
| 67 | * |
||
| 68 | * @param string $subtype |
||
| 69 | * |
||
| 70 | * @return TextField |
||
| 71 | */ |
||
| 72 | public function withSubtype(string $subtype = 'text') |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Get field subtype. |
||
| 79 | * |
||
| 80 | * @return string |
||
| 81 | */ |
||
| 82 | public function subtype() |
||
| 87 |