Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Report.php
diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Report.php b/web/modules/contrib/drupalmoduleupgrader/src/Report.php
new file mode 100644 (file)
index 0000000..995a1f4
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+namespace Drupal\drupalmoduleupgrader;
+
+/**
+ * Basic implementation of an analyzer report.
+ */
+class Report implements ReportInterface {
+
+  /**
+   * @var \Drupal\drupalmoduleupgrader\IssueInterface[]
+   */
+  protected $issues = [];
+
+  /**
+   * {@inheritdoc}
+   */
+  public function addIssue(IssueInterface $issue) {
+    $id = spl_object_hash($issue);
+    $this->issues[$id] = $issue;
+    return $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getIssues($tag = NULL) {
+    // We call array_values() here to reset the keys.
+    $issues = array_values($this->issues);
+
+    if ($tag) {
+      $issues = array_filter($issues, function(IssueInterface $issue) use ($tag) {
+        return $issue->hasTag($tag);
+      });
+    }
+
+    return $issues;
+  }
+
+  public function enumerateTag($tag) {
+    $enum = array_map(function(IssueInterface $issue) use ($tag) { return $issue->getTag($tag); }, $this->getIssues($tag));
+    return array_unique($enum);
+  }
+
+}