parseCSV::_validate_row_conditions PHP Method

_validate_row_conditions() public method

Validate a row against specified conditions
public _validate_row_conditions ( $row = [], $conditions = null ) : true
return true of false
    function _validate_row_conditions($row = [], $conditions = null)
    {
        if (!empty($row)) {
            if (!empty($conditions)) {
                $conditions = strpos($conditions, ' OR ') !== false ? explode(' OR ', $conditions) : [$conditions];
                $or = '';
                foreach ($conditions as $key => $value) {
                    if (strpos($value, ' AND ') !== false) {
                        $value = explode(' AND ', $value);
                        $and = '';
                        foreach ($value as $k => $v) {
                            $and .= $this->_validate_row_condition($row, $v);
                        }
                        $or .= strpos($and, '0') !== false ? '0' : '1';
                    } else {
                        $or .= $this->_validate_row_condition($row, $value);
                    }
                }
                return strpos($or, '1') !== false ? true : false;
            }
            return true;
        }
        return false;
    }