Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Select
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
4 / 4
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 name
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 option
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 required
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Epic64\Elem\Elements;
6
7use Epic64\Elem\Element;
8
9class Select extends Element
10{
11    public function __construct(?string $name = null)
12    {
13        parent::__construct('select');
14        if ($name !== null) {
15            $this->element->setAttribute('name', $name);
16        }
17    }
18
19    public function name(string $name): static
20    {
21        return $this->attr('name', $name);
22    }
23
24    public function option(string $value, string $text, bool $selected = false): static
25    {
26        $option = new Option($value, $text, $selected);
27        $this($option);
28        return $this;
29    }
30
31    public function required(): static
32    {
33        return $this->attr('required', 'required');
34    }
35}