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

StaticItem::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
use Assert\Assertion;
6
use PhpSchool\CliMenu\MenuStyle;
7
use PhpSchool\CliMenu\Util\StringUtil;
8
9
/**
10
 * @author Michael Woodward <[email protected]>
11
 */
12
class StaticItem implements MenuItemInterface
13
{
14
    /**
15
     * @var string
16
     */
17
    private $text;
18
19
    public function __construct(string $text)
20
    {
21
        $this->text = $text;
22
    }
23
24
    /**
25
     * The output text for the item
26
     */
27
    public function getRows(MenuStyle $style, bool $selected = false) : array
28
    {
29
        return explode("\n", StringUtil::wordwrap($this->text, $style->getContentWidth()));
30
    }
31
32
    /**
33
     * Can the item be selected
34
     */
35
    public function canSelect() : bool
36
    {
37
        return false;
38
    }
39
40
    /**
41
     * Execute the items callable if required
42
     */
43
    public function getSelectAction() : ?callable
44
    {
45
        return null;
46
    }
47
48
    /**
49
     * Return the raw string of text
50
     */
51
    public function getText() : string
52
    {
53
        return $this->text;
54
    }
55
56
    /**
57
     * Set the raw string of text
58
     */
59
    public function setText(string $text) : void
60
    {
61
        $this->text = $text;
62
    }
63
64
    /**
65
     * Whether or not the menu item is showing the menustyle extra value
66
     */
67
    public function showsItemExtra() : bool
68
    {
69
        return false;
70
    }
71
72
    /**
73
     * Enable showing item extra
74
     */
75
    public function showItemExtra() : void
76
    {
77
        //noop
78
    }
79
80
    /**
81
     * Disable showing item extra
82
     */
83
    public function hideItemExtra() : void
84
    {
85
        //noop
86
    }
87
}
88