Completed
Pull Request — master (#77)
by
unknown
03:23
created

SelectableItem::getData()   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 0
1
<?php
2
3
namespace PhpSchool\CliMenu\MenuItem;
4
5
use Assert\Assertion;
6
7
/**
8
 * Class SelectableItem
9
 *
10
 * @package PhpSchool\CliMenu\MenuItem
11
 * @author Michael Woodward <[email protected]>
12
 */
13
class SelectableItem implements MenuItemInterface
14
{
15
    use SelectableTrait;
16
17
    /**
18
     * @var callable
19
     */
20
    private $selectAction;
21
22
    /**
23
     * @param string $text
24
     * @param callable $selectAction
25
     * @param bool $showItemExtra
26
     * @param bool $disabled
27
     */
28
    public function __construct($text, callable $selectAction, $data = [], $showItemExtra = false, $disabled = false)
29
    {
30
        Assertion::string($text);
31
     
32
        $this->text          = $text;
33
        $this->data          = $data;
0 ignored issues
show
Bug introduced by
The property data does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
34
        $this->selectAction  = $selectAction;
35
        $this->showItemExtra = (bool) $showItemExtra;
36
        $this->disabled      = $disabled;
37
    }
38
39
    /**
40
     * Execute the items callable if required
41
     *
42
     * @return callable|void
43
     */
44
    public function getSelectAction()
45
    {
46
        return $this->selectAction;
47
    }
48
49
    /**
50
     * Return the raw string of text
51
     *
52
     * @return string
53
     */
54
    public function getText()
55
    {
56
        return $this->text;
57
    }
58
    
59
    /**
60
     * Return the raw data
61
     *
62
     * @return array
63
     */
64
    public function getData()
65
    {
66
        return $this->data;
67
    }
68
}
69