Author: Michael Woodward (mikeymike.mw@gmail.com)
Author: Aydin Hassan (aydin@hotmail.com)
Ejemplo n.º 1
0
 /**
  * Recursively drop back to the parents menu style
  * when the current menu has a parent and has no changes
  *
  * @return MenuStyle
  */
 private function getMenuStyle()
 {
     if (null === $this->parent) {
         return $this->buildStyle();
     }
     if ($this->style !== MenuStyle::getDefaultStyleValues()) {
         return $this->buildStyle();
     }
     return $this->parent->getMenuStyle();
 }
Ejemplo n.º 2
0
 /**
  * Recursively drop back to the parents menu style
  * when the current menu has a parent and has no changes
  *
  * @return MenuStyle
  */
 private function getMenuStyle()
 {
     $diff = array_udiff_assoc($this->style, $this->getStyleClassDefaults(), function ($current, $default) {
         if ($current instanceof TerminalInterface) {
             return 0;
         }
         return $current === $default ? 0 : 1;
     });
     if (!$diff && null !== $this->parent) {
         return $this->parent->getMenuStyle();
     }
     return new MenuStyle(...array_values($this->style));
 }
Ejemplo n.º 3
0
 public function testAddSubMenu()
 {
     $builder = new CliMenuBuilder();
     $builder->disableDefaultItems();
     $subMenuBuilder = $builder->addSubMenu('sub-menu');
     $menu = $builder->build();
     $this->checkItems($menu, [['class' => MenuMenuItem::class]]);
     $this->assertInstanceOf(CliMenuBuilder::class, $subMenuBuilder);
     $this->assertNotSame($subMenuBuilder, $builder);
     $this->assertSame($builder, $subMenuBuilder->end());
 }