Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Report.php
1 <?php
2
3 namespace Drupal\drupalmoduleupgrader;
4
5 /**
6  * Basic implementation of an analyzer report.
7  */
8 class Report implements ReportInterface {
9
10   /**
11    * @var \Drupal\drupalmoduleupgrader\IssueInterface[]
12    */
13   protected $issues = [];
14
15   /**
16    * {@inheritdoc}
17    */
18   public function addIssue(IssueInterface $issue) {
19     $id = spl_object_hash($issue);
20     $this->issues[$id] = $issue;
21     return $this;
22   }
23
24   /**
25    * {@inheritdoc}
26    */
27   public function getIssues($tag = NULL) {
28     // We call array_values() here to reset the keys.
29     $issues = array_values($this->issues);
30
31     if ($tag) {
32       $issues = array_filter($issues, function(IssueInterface $issue) use ($tag) {
33         return $issue->hasTag($tag);
34       });
35     }
36
37     return $issues;
38   }
39
40   public function enumerateTag($tag) {
41     $enum = array_map(function(IssueInterface $issue) use ($tag) { return $issue->getTag($tag); }, $this->getIssues($tag));
42     return array_unique($enum);
43   }
44
45 }