Completed
Push — master ( 306131...5909ec )
by Aydin
06:33 queued 03:57
created

SelectableItem   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getSelectAction() 0 4 1
A getText() 0 4 1
A setText() 0 4 1
1
<?php
2
3
namespace PhpSchool\CliMenu\MenuItem;
4
5
/**
6
 * @author Michael Woodward <[email protected]>
7
 */
8
class SelectableItem implements MenuItemInterface
9
{
10
    use SelectableTrait;
11
12
    /**
13
     * @var callable
14
     */
15
    private $selectAction;
16
17
    public function __construct(
18
        string $text,
19
        callable $selectAction,
20
        bool $showItemExtra = false,
21
        bool $disabled = false
22
    ) {
23
        $this->text          = $text;
24
        $this->selectAction  = $selectAction;
25
        $this->showItemExtra = $showItemExtra;
26
        $this->disabled      = $disabled;
27
    }
28
29
    /**
30
     * Execute the items callable if required
31
     */
32
    public function getSelectAction() : ?callable
33
    {
34
        return $this->selectAction;
35
    }
36
37
    /**
38
     * Return the raw string of text
39
     */
40
    public function getText() : string
41
    {
42
        return $this->text;
43
    }
44
45
    /**
46
     * Set the raw string of text
47
     */
48
    public function setText(string $text) : void
49
    {
50
        $this->text = $text;
51
    }
52
}
53