diff options
author | diosmosis <benaka@piwik.pro> | 2014-09-21 02:52:43 +0400 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2014-09-21 03:02:41 +0400 |
commit | 89ce428063338b24cf229f44c7a716abfeae1674 (patch) | |
tree | a5f6aa18a741bd224714d83587e0432091989780 /core/DataTable/Filter/PivotByDimension.php | |
parent | 3101516bd671937e297dabc423576c315a60e135 (diff) |
Refs #6078, remove dead code & refactor dimension equality checks in PivotByDimension filter.
Diffstat (limited to 'core/DataTable/Filter/PivotByDimension.php')
-rw-r--r-- | core/DataTable/Filter/PivotByDimension.php | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/core/DataTable/Filter/PivotByDimension.php b/core/DataTable/Filter/PivotByDimension.php index fd176f8cf5..b3d5a3b5e3 100644 --- a/core/DataTable/Filter/PivotByDimension.php +++ b/core/DataTable/Filter/PivotByDimension.php @@ -274,7 +274,7 @@ class PivotByDimension extends BaseFilter private function isPivotDimensionSubtable() { - return !empty($this->subtableDimension) && $this->subtableDimension->getId() == $this->pivotByDimension->getId(); + return self::areDimensionsEqualAndNotNull($this->subtableDimension, $this->pivotByDimension); } private function loadSubtable(DataTable $table, Row $row) @@ -353,7 +353,7 @@ class PivotByDimension extends BaseFilter throw new Exception("Unsupported pivot: report '$reportId' has no subtable dimension."); } - if ($this->subtableDimension->getId() !== $this->pivotByDimension->getId()) { + if (!$this->isPivotDimensionSubtable()) { throw new Exception("Unsupported pivot: the subtable dimension for '$reportId' does not match the " . "requested pivotBy dimension. [subtable dimension = {$this->subtableDimension->getId()}, " . "pivot by dimension = {$this->pivotByDimension->getId()}]"); @@ -487,8 +487,7 @@ class PivotByDimension extends BaseFilter */ public static function isPivotingReportBySubtableSupported(Report $report) { - $subtableDimension = $report->getSubtableDimension(); - return !empty($subtableDimension) && $subtableDimension->getId() !== $report->getDimension()->getId(); + return self::areDimensionsNotEqualAndNotNull($report->getSubtableDimension(), $report->getDimension()); } /** @@ -511,4 +510,24 @@ class PivotByDimension extends BaseFilter { return Config::getInstance()->General['pivot_by_filter_default_column_limit']; } + + /** + * @param Dimension|null $lhs + * @param Dimension|null $rhs + * @return bool + */ + private static function areDimensionsEqualAndNotNull($lhs, $rhs) + { + return !empty($lhs) && !empty($rhs) && $lhs->getId() == $rhs->getId(); + } + + /** + * @param Dimension|null $lhs + * @param Dimension|null $rhs + * @return bool + */ + private static function areDimensionsNotEqualAndNotNull($lhs, $rhs) + { + return !empty($lhs) && !empty($rhs) && $lhs->getId() != $rhs->getId(); + } }
\ No newline at end of file |