/**
  * {@inheritdoc}
  */
 public function createEntry(Card $card)
 {
     $entry = new Entry();
     $entry->version = $card->name;
     $entry->date = new \DateTime($card->due);
     foreach ($card->checklists as $checklist) {
         $entry->addSection($this->createSection($checklist));
     }
     return $entry;
 }
Exemple #2
0
 public function testSections()
 {
     $e = new Entry();
     $this->assertEmpty($e->getSections());
     $s1 = new Section();
     $e->addSection($s1);
     $this->assertCount(1, $e->getSections());
     $this->assertSame($s1, $e->getSections()[0]);
     $s2 = new Section();
     $e->addSection($s2);
     $this->assertCount(2, $e->getSections());
     $this->assertSame($s1, $e->getSections()[0]);
     $this->assertSame($s2, $e->getSections()[1]);
 }
 /**
  * {@inheritdoc}
  */
 public function printEntry(Entry $entry)
 {
     $whiteList = $this->getOption('sections_whitelist');
     $blackList = $this->getOption('sections_blacklist');
     $sectionOuts = [];
     foreach ($entry->getSections() as $section) {
         if (!$this->checkWhiteAndBlackLists($section->name, $whiteList, $blackList)) {
             continue;
         }
         $sectionOut = $this->printSection($section);
         if (!empty($sectionOut)) {
             $sectionOuts[] = $sectionOut;
         }
     }
     if (empty($sectionOuts)) {
         return '';
     }
     $out = ['## ' . $this->formatVersion($entry->version) . ' - ' . $entry->date->format('Y-m-d')];
     $out[] = join(PHP_EOL . PHP_EOL, $sectionOuts);
     return join(PHP_EOL, $out);
 }