PhpSchool\CliMenu\MenuItem\MenuItemInterface::getRows PHP Method

getRows() public method

The output text for the item
public getRows ( MenuStyle $style, boolean $selected = false ) : array
$style PhpSchool\CliMenu\MenuStyle
$selected boolean
return array
    public function getRows(MenuStyle $style, $selected = false);

Usage Example

Beispiel #1
0
 /**
  * Draw a menu item
  *
  * @param MenuItemInterface $item
  * @param bool|false $selected
  * @return array
  */
 protected function drawMenuItem(MenuItemInterface $item, $selected = false)
 {
     $rows = $item->getRows($this->style, $selected);
     $setColour = $selected ? $this->style->getSelectedSetCode() : $this->style->getUnselectedSetCode();
     $unsetColour = $selected ? $this->style->getSelectedUnsetCode() : $this->style->getUnselectedUnsetCode();
     return array_map(function ($row) use($setColour, $unsetColour) {
         return sprintf("%s%s%s%s%s%s%s\n\r", str_repeat(' ', $this->style->getMargin()), $setColour, str_repeat(' ', $this->style->getPadding()), $row, str_repeat(' ', $this->style->getRightHandPadding(mb_strlen(s::stripAnsiEscapeSequence($row)))), $unsetColour, str_repeat(' ', $this->style->getMargin()));
     }, $rows);
 }
All Usage Examples Of PhpSchool\CliMenu\MenuItem\MenuItemInterface::getRows