PhpSchool\CliMenu\MenuStyle::getMarker PHP Method

getMarker() public method

Get the correct marker for the item
public getMarker ( boolean $selected ) : string
$selected boolean
return string
    public function getMarker($selected)
    {
        return $selected ? $this->selectedMarker : $this->unselectedMarker;
    }

Usage Example

Example #1
0
 /**
  * The output text for the item
  *
  * @param MenuStyle $style
  * @param bool $selected
  * @return array
  */
 public function getRows(MenuStyle $style, $selected = false)
 {
     $marker = sprintf("%s ", $style->getMarker($selected));
     $length = $style->getDisplaysExtra() ? $style->getContentWidth() - (mb_strlen($style->getItemExtra()) + 2) : $style->getContentWidth();
     $rows = explode("\n", StringUtil::wordwrap(sprintf('%s%s', $marker, $this->text), $length, sprintf("\n%s", str_repeat(' ', mb_strlen($marker)))));
     return array_map(function ($row, $key) use($style, $marker, $length) {
         if ($key === 0) {
             return $this->showItemExtra ? sprintf('%s%s  %s', $row, str_repeat(' ', $length - mb_strlen($row)), $style->getItemExtra()) : $row;
         }
         return $row;
     }, $rows, array_keys($rows));
 }