Code Duplication    Length = 36-36 lines in 2 locations

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

@@ 291-326 (lines=36) @@
288
     *
289
     * @return bool
290
     */
291
    public function isDisplayed(array $row)
292
    {
293
        if ($this->hasShowOnValues() === false) {
294
            return true;
295
        }
296
297
        $isDisplayed = false;
298
        foreach ($this->getShowOnValues() as $rule) {
299
            $value = '';
300
            if (isset($row[$rule['column']->getUniqueId()])) {
301
                $value = $row[$rule['column']->getUniqueId()];
302
            }
303
304
            if ($rule['value'] instanceof AbstractColumn) {
305
                if (isset($row[$rule['value']->getUniqueId()])) {
306
                    $ruleValue = $row[$rule['value']->getUniqueId()];
307
                } else {
308
                    $ruleValue = '';
309
                }
310
            } else {
311
                $ruleValue = $rule['value'];
312
            }
313
314
            $isDisplayedMatch = Filter::isApply($value, $ruleValue, $rule['comparison']);
315
            if ($this->getShowOnValueOperator() == 'OR' && true === $isDisplayedMatch) {
316
                // For OR one match is enough
317
                return true;
318
            } elseif ($this->getShowOnValueOperator() == 'AND' && false === $isDisplayedMatch) {
319
                return false;
320
            } else {
321
                $isDisplayed = $isDisplayedMatch;
322
            }
323
        }
324
325
        return $isDisplayed;
326
    }
327
328
    /**
329
     * Get the HTML from the type.

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