diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2019-05-13 04:11:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-13 04:11:18 +0300 |
commit | 1b2ee7fc984580d57ab63fde61843a3974016149 (patch) | |
tree | 839c748410a899731570d7bb9cc62ebe701c6d53 /core | |
parent | 7b56ad807f0ca132c3ddb83fde10efd08ad2b9c4 (diff) |
Allow Metric instances to be stored in Report::$metrics. (#14414)
Diffstat (limited to 'core')
-rw-r--r-- | core/Plugin/Report.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/core/Plugin/Report.php b/core/Plugin/Report.php index 04145a2d40..05bc731ca0 100644 --- a/core/Plugin/Report.php +++ b/core/Plugin/Report.php @@ -485,8 +485,18 @@ class Report $documentation = array(); foreach ($this->metrics as $metric) { - if (!empty($translations[$metric])) { + if (is_string($metric) && !empty($translations[$metric])) { $documentation[$metric] = $translations[$metric]; + } elseif ($metric instanceof Metric) { + $name = $metric->getName(); + $metricDocs = $metric->getDocumentation(); + if (empty($metricDocs)) { + $metricDocs = @$translations[$name]; + } + + if (!empty($metricDocs)) { + $documentation[$name] = $metricDocs; + } } } @@ -494,7 +504,7 @@ class Report foreach ($processedMetrics as $processedMetric) { if (is_string($processedMetric) && !empty($translations[$processedMetric])) { $documentation[$processedMetric] = $translations[$processedMetric]; - } elseif ($processedMetric instanceof ProcessedMetric) { + } elseif ($processedMetric instanceof Metric) { $name = $processedMetric->getName(); $metricDocs = $processedMetric->getDocumentation(); if (empty($metricDocs)) { @@ -502,7 +512,7 @@ class Report } if (!empty($metricDocs)) { - $documentation[$processedMetric->getName()] = $metricDocs; + $documentation[$name] = $metricDocs; } } } |