for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpSchool\CliMenu\MenuItem;
trait ToggableTrait
{
/**
* @var callable
*/
private $selectAction;
private $text = '';
private $showItemExtra = false;
private $disabled = false;
private $checked = false;
* Toggles checked state
public function toggle() : void
$this->checked = !$this->checked;
}
* Sets checked state to true
public function setChecked() : void
$this->checked = true;
* Sets checked state to false
public function setUnchecked() : void
$this->checked = false;
* Whether or not the item is checked
public function getChecked() : bool
return $this->checked;
* Return the raw string of text
public function getText() : string
return $this->text;
* Set the raw string of text
public function setText(string $text) : void
$this->text = $text;
* Can the item be selected
public function canSelect() : bool
return !$this->disabled;
public function showsItemExtra() : bool
return $this->showItemExtra;
* Enable showing item extra
public function showItemExtra() : void
$this->showItemExtra = true;
* Disable showing item extra
public function hideItemExtra() : void
$this->showItemExtra = false;