Code Duplication    Length = 36-36 lines in 2 locations

src/ZfcDatagrid/Column/Style/AbstractStyle.php 1 location

@@ 83-118 (lines=36) @@
80
     *
81
     * @return bool
82
     */
83
    public function isApply(array $row)
84
    {
85
        if ($this->hasByValues() === false) {
86
            return true;
87
        }
88
89
        $isApply = false;
90
        foreach ($this->getByValues() as $rule) {
91
            $value = '';
92
            if (isset($row[$rule['column']->getUniqueId()])) {
93
                $value = $row[$rule['column']->getUniqueId()];
94
            }
95
96
            if ($rule['value'] instanceof AbstractColumn) {
97
                if (isset($row[$rule['value']->getUniqueId()])) {
98
                    $ruleValue = $row[$rule['value']->getUniqueId()];
99
                } else {
100
                    $ruleValue = '';
101
                }
102
            } else {
103
                $ruleValue = $rule['value'];
104
            }
105
106
            $isApplyMatch = Filter::isApply($value, $ruleValue, $rule['operator']);
107
            if ($this->getByValueOperator() == 'OR' && true === $isApplyMatch) {
108
                // For OR one match is enough
109
                return true;
110
            } elseif ($this->getByValueOperator() == 'AND' && false === $isApplyMatch) {
111
                return false;
112
            } else {
113
                $isApply = $isApplyMatch;
114
            }
115
        }
116
117
        return $isApply;
118
    }
119
}
120

src/ZfcDatagrid/Column/Action/AbstractAction.php 1 location

@@ 333-368 (lines=36) @@
330
     *
331
     * @return bool
332
     */
333
    public function isDisplayed(array $row)
334
    {
335
        if ($this->hasShowOnValues() === false) {
336
            return true;
337
        }
338
339
        $isDisplayed = false;
340
        foreach ($this->getShowOnValues() as $rule) {
341
            $value = '';
342
            if (isset($row[$rule['column']->getUniqueId()])) {
343
                $value = $row[$rule['column']->getUniqueId()];
344
            }
345
346
            if ($rule['value'] instanceof AbstractColumn) {
347
                if (isset($row[$rule['value']->getUniqueId()])) {
348
                    $ruleValue = $row[$rule['value']->getUniqueId()];
349
                } else {
350
                    $ruleValue = '';
351
                }
352
            } else {
353
                $ruleValue = $rule['value'];
354
            }
355
356
            $isDisplayedMatch = Filter::isApply($value, $ruleValue, $rule['comparison']);
357
            if ($this->getShowOnValueOperator() == 'OR' && true === $isDisplayedMatch) {
358
                // For OR one match is enough
359
                return true;
360
            } elseif ($this->getShowOnValueOperator() == 'AND' && false === $isDisplayedMatch) {
361
                return false;
362
            } else {
363
                $isDisplayed = $isDisplayedMatch;
364
            }
365
        }
366
367
        return $isDisplayed;
368
    }
369
370
    /**
371
     * Get the HTML from the type.