コード例 #1
0
 public function getVersions()
 {
     $parser = new Markdown();
     $currentVersion = null;
     $currentLabel = null;
     foreach (new \SplFileObject($this->filePath) as $line) {
         if (preg_match($this->regex['version'], $line, $matches)) {
             if (null !== $currentVersion) {
                 $this->versions->add($currentVersion);
             }
             $currentVersion = new Version();
             $currentVersion->setVersion($matches[1]);
             if ($currentVersion->isReleased()) {
                 if (array_key_exists(2, $matches)) {
                     $currentVersion->setUrl($matches[2]);
                 }
                 if (array_key_exists(3, $matches)) {
                     $currentVersion->setReleaseDate(new \DateTime($matches[3]));
                 }
             }
             $currentVersion->setYanked(in_array('[YANKED]', $matches));
         } else {
             if (preg_match($this->regex['changes_url'], $line, $matches)) {
                 //$fullChangelogUrl = $matches[0]; // Currently not used
             } else {
                 if (preg_match($this->regex['label'], $line, $matches)) {
                     $currentLabel = $this->translator->translateFrom(strtolower($matches[1]));
                 } else {
                     if (preg_match($this->regex['change'], $line, $matches)) {
                         $change = $this->removeIssues ? preg_replace('/#\\d+/', '', $matches[1]) : $matches[1];
                         $currentVersion->addChange($currentLabel, $parser->parseParagraph($change));
                     }
                 }
             }
         }
     }
     if (null !== $currentVersion) {
         $this->versions->add($currentVersion);
     }
     return $this->versions;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function addDocumentation($url, $title)
 {
     $this->documentation[] = ['url' => $url, 'title' => $this->parser->parseParagraph($title)];
     return $this;
 }