You are here

class Report in Drupal 7 to 8/9 Module Upgrader 8

Basic implementation of an analyzer report.

Hierarchy

Expanded class hierarchy of Report

3 files declare their use of Report
drupalmoduleupgrader.drush.inc in ./drupalmoduleupgrader.drush.inc
Declarations for Drush.
DrupalmoduleupgraderCommands.php in src/Commands/DrupalmoduleupgraderCommands.php
ReportTest.php in tests/src/Unit/ReportTest.php
1 string reference to 'Report'
drupalmoduleupgrader_theme in ./drupalmoduleupgrader.module
Implements hook_theme().

File

src/Report.php, line 8

Namespace

Drupal\drupalmoduleupgrader
View source
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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Report::$issues protected property
Report::addIssue public function Adds an issue to this module. Overrides ReportInterface::addIssue
Report::enumerateTag public function
Report::getIssues public function Returns all issues collected so far, optionally filtered by a tag. Overrides ReportInterface::getIssues