for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpSchool\CliMenu\MenuItem;
use Assert\Assertion;
/**
* Class SelectableItem
*
* @package PhpSchool\CliMenu\MenuItem
* @author Michael Woodward <[email protected]>
*/
class SelectableItem implements MenuItemInterface
{
use SelectableTrait;
* @var callable
private $selectAction;
* @param string $text
* @param callable $selectAction
* @param bool $showItemExtra
* @param bool $disabled
public function __construct($text, callable $selectAction, $data = [], $showItemExtra = false, $disabled = false)
Assertion::string($text);
$this->text = $text;
$this->data = $data;
data
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;
$this->selectAction = $selectAction;
$this->showItemExtra = (bool) $showItemExtra;
$this->disabled = $disabled;
}
* Execute the items callable if required
* @return callable|void
public function getSelectAction()
return $this->selectAction;
* Return the raw string of text
* @return string
public function getText()
return $this->text;
* Return the raw data
* @return array
public function getData()
return $this->data;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: