Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function createSection(array $checkList)
 {
     ArrayArgument::requireKeys('First argument', ['name', 'checkItems'], $checkList);
     $section = new Section();
     $section->name = $checkList['name'];
     foreach ((array) $checkList['checkItems'] as $checkItem) {
         $section->addItem($this->createItem($checkItem));
     }
     return $section;
 }
Ejemplo n.º 2
0
 public function testItems()
 {
     $s = new Section();
     $this->assertEmpty($s->getItems());
     $i1 = new Item();
     $s->addItem($i1);
     $this->assertCount(1, $s->getItems());
     $this->assertSame($i1, $s->getItems()[0]);
     $i2 = new Item();
     $s->addItem($i2);
     $this->assertCount(2, $s->getItems());
     $this->assertSame($i1, $s->getItems()[0]);
     $this->assertSame($i2, $s->getItems()[1]);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function printSection(Section $section)
 {
     $items = $section->getItems();
     $isEmpty = count($items) == 0;
     if ($isEmpty && !$this->getOption('print_empty_sections')) {
         return '';
     }
     $out = ['### ' . $section->name];
     if ($isEmpty) {
         $out[] = $this->getOption('empty_section_template');
     } else {
         foreach ($items as $item) {
             $out[] = $this->printItem($item);
         }
     }
     return join(PHP_EOL, $out);
 }