/** * Captures custom date arguments * * @param array $args * @return void */ protected function __captureCustomDateArgs(array &$args = array()) { foreach ($args as $key => $value) { if (preg_match('/^year\\:/', $key) || preg_match('/^month\\:/', $key) || preg_match('/^day\\:/', $key) || preg_match('/^week\\:/', $key) || preg_match('/^hour\\:/', $key) || preg_match('/^minute\\:/', $key) || preg_match('/^second\\:/', $key)) { $data = explode(':', $key); $date_key = isset($data[0]) ? $data[0] : null; $compare = isset($data[1]) ? $data[1] : '='; unset($args[$key]); if (array_key_exists(strtolower($compare), static::$comparator_map)) { $compare = static::$comparator_map[$compare]; $values = explode(',', $value); $value = count($values) == 1 && !in_array($compare, array('IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN')) ? $values[0] : $values; $data = array($date_key => $value, 'compare' => $compare); if (!$this->clean_args->hasKey('date_query')) { $relation = 'AND'; if (isset($args['date_relation'])) { $relation = $args['date_relation']; unset($args['date_relation']); } $this->clean_args->set('date_query.relation', $relation); } $this->clean_args->push($data, 'date_query'); } } } }
/** * Checks if the target var key have a value * * @param string $key Target var key * @return boolean True if there is a value, false otherwise */ public function varHasValue($key) { return $this->vars->hasKey($key) && $this->vars->get($key) != '' ? true : false; }