/** * @param CliMenuBuilder|null $parent */ public function __construct(CliMenuBuilder $parent = null) { $this->parent = $parent; $this->terminal = TerminalFactory::fromSystem(); $this->style = $this->getStyleClassDefaults(); $this->style['terminal'] = $this->terminal; }
/** * @param string $title * @param array $items * @param TerminalInterface|null $terminal * @param MenuStyle|null $style * * @throws InvalidTerminalException */ public function __construct($title, array $items, TerminalInterface $terminal = null, MenuStyle $style = null) { $this->title = $title; $this->items = $items; $this->terminal = $terminal ?: TerminalFactory::fromSystem(); $this->style = $style ?: new MenuStyle($this->terminal); $this->selectFirstItem(); }
/** * @param string $title * @param array $items * @param TerminalInterface|null $terminal * @param MenuStyle|null $style * @throws InvalidInstantiationException * @throws InvalidTerminalException */ public function __construct($title, array $items, TerminalInterface $terminal = null, MenuStyle $style = null) { $builder = debug_backtrace(); if (count($builder) < 2 || !isset($builder[1]['class']) || $builder[1]['class'] !== $this->allowedConsumer) { throw new InvalidInstantiationException(sprintf('The CliMenu must be instantiated by "%s"', $this->allowedConsumer)); } $this->title = $title; $this->items = $items; $this->terminal = $terminal ?: TerminalFactory::fromSystem(); $this->style = $style ?: new MenuStyle(); $this->selectFirstItem(); }
/** * Initialise style * * @param string $bg * @param string $fg * @param int $width * @param int $padding * @param int $margin * @param string $unselectedMarker * @param string $selectedMarker * @param string $itemExtra * @param bool $displaysExtra * @param string $titleSeparator * @param TerminalInterface $terminal * @throws InvalidInstantiationException */ public function __construct($bg = 'blue', $fg = 'white', $width = 100, $padding = 2, $margin = 2, $unselectedMarker = '○', $selectedMarker = '●', $itemExtra = '✔', $displaysExtra = false, $titleSeparator = '=', TerminalInterface $terminal = null) { $builder = debug_backtrace(); if (count($builder) < 2 || !isset($builder[1]['class']) || $builder[1]['class'] !== $this->allowedConsumer) { throw new InvalidInstantiationException(sprintf('The CliMenu must be instantiated by "%s"', $this->allowedConsumer)); } $this->terminal = $terminal ?: TerminalFactory::fromSystem(); $this->bg = $bg; $this->fg = $fg; $this->padding = $padding; $this->margin = $margin; $this->itemExtra = $itemExtra; $this->displaysExtra = $displaysExtra; $this->titleSeparator = $titleSeparator; $this->setUnselectedMarker($unselectedMarker); $this->setSelectedMarker($selectedMarker); $this->setWidth($width); $this->calculateContentWidth(); }
/** * @param CliMenuBuilder|null $parent */ public function __construct(CliMenuBuilder $parent = null) { $this->parent = $parent; $this->terminal = TerminalFactory::fromSystem(); $this->style = MenuStyle::getDefaultStyleValues(); }
/** * Initialise style * * @param TerminalInterface $terminal */ public function __construct(TerminalInterface $terminal = null) { $this->terminal = $terminal ?: TerminalFactory::fromSystem(); $this->setFg(static::$defaultStyleValues['fg']); $this->setBg(static::$defaultStyleValues['bg']); $this->setWidth(static::$defaultStyleValues['width']); $this->setPadding(static::$defaultStyleValues['padding']); $this->setMargin(static::$defaultStyleValues['margin']); $this->setSelectedMarker(static::$defaultStyleValues['selectedMarker']); $this->setUnselectedMarker(static::$defaultStyleValues['unselectedMarker']); $this->setItemExtra(static::$defaultStyleValues['itemExtra']); $this->setDisplaysExtra(static::$defaultStyleValues['displaysExtra']); $this->setTitleSeparator(static::$defaultStyleValues['titleSeparator']); }