PhpSchool\CliMenu\MenuStyle::getUnselectedSetCode PHP Method

getUnselectedSetCode() public method

Get the inverted colour code
public getUnselectedSetCode ( ) : string
return string
    public function getUnselectedSetCode()
    {
        return sprintf("[%sm", implode(';', [self::$availableBackgroundColors[$this->getBg()]['set'], self::$availableForegroundColors[$this->getFg()]['set']]));
    }

Usage Example

Example #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\MenuStyle::getUnselectedSetCode