Option   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A selected() 0 4 1
A selectedIf() 0 6 2
A unselected() 0 4 1
1
<?php
2
3
namespace Spatie\Html\Elements;
4
5
use Spatie\Html\BaseElement;
6
use Spatie\Html\Elements\Attributes\Value;
7
use Spatie\Html\Selectable;
8
9
class Option extends BaseElement implements Selectable
10
{
11
    use Value;
12
13
    /** @var string */
14
    protected $tag = 'option';
15
16
    /**
17
     * @return static
18
     */
19
    public function selected()
20
    {
21
        return $this->attribute('selected', 'selected');
22
    }
23
24
    /**
25
     * @param bool $condition
26
     *
27
     * @return static
28
     */
29
    public function selectedIf($condition)
30
    {
31
        return $condition ?
32
            $this->selected() :
33
            $this->unselected();
34
    }
35
36
    /**
37
     * @return static
38
     */
39
    public function unselected()
40
    {
41
        return $this->forgetAttribute('selected');
42
    }
43
}
44