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

SelectableItem::setText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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