/** * 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)); }
/** * The output text for the item * * @param MenuStyle $style * @param bool $selected * @return array */ public function getRows(MenuStyle $style, $selected = false) { return array_map(function ($row) use($style) { $length = mb_strlen($row); $padding = $style->getContentWidth() - $length; switch ($this->position) { case self::POSITION_LEFT: return $row; break; case self::POSITION_RIGHT: $row = rtrim($row); $padding = $padding - ($this->artLength - mb_strlen($row)); $row = sprintf('%s%s', str_repeat(' ', $padding), $row); break; case self::POSITION_CENTER: default: $row = rtrim($row); $padding = $padding - ($this->artLength - mb_strlen($row)); $left = ceil($padding / 2); $right = $padding - $left; $row = sprintf('%s%s%s', str_repeat(' ', $left), $row, str_repeat(' ', $right)); break; } return $row; }, explode("\n", $this->text)); }
/** * The output text for the item * * @param MenuStyle $style * @param bool $selected * @return array */ public function getRows(MenuStyle $style, $selected = false) { return explode("\n", StringUtil::wordwrap($this->text, $style->getContentWidth())); }
/** * The output text for the item * * @param MenuStyle $style * @param bool $selected * @return array */ public function getRows(MenuStyle $style, $selected = false) { return explode("\n", rtrim(str_repeat(sprintf("%s\n", mb_substr(str_repeat($this->breakChar, $style->getContentWidth()), 0, $style->getContentWidth())), $this->lines))); }