Code Duplication    Length = 36-36 lines in 2 locations

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

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

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

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