Ejemplo n.º 1
0
 /**
  * Prepare the accepted date values for the API call.
  *
  * @param $parameters
  * @param null $action
  */
 private function sanitizeDateRange(&$parameters, $action = null)
 {
     if (is_null($action)) {
         $actions = ['opened', 'resolved', 'closed'];
         foreach ($actions as $action) {
             $this->sanitizeDateRange($parameters, $action);
         }
         return;
     }
     $elements = [];
     if (isset($parameters[$action . '_from']) && isset($parameters[$action . '_until'])) {
         array_push($elements, '><');
         array_push($elements, normalizeDateOnly($parameters[$action . '_from']));
         array_push($elements, '|');
         array_push($elements, normalizeDateOnly($parameters[$action . '_until']));
     } else {
         if (isset($parameters[$action . '_from'])) {
             array_push($elements, '>=');
             array_push($elements, normalizeDateOnly($parameters[$action . '_from']));
         } else {
             if (isset($parameters[$action . '_until'])) {
                 array_push($elements, '<=');
                 array_push($elements, normalizeDateOnly($parameters[$action . '_until']));
             } else {
                 if (isset($parameters[$action . '_on'])) {
                     array_push($elements, '=');
                     array_push($elements, normalizeDateOnly($parameters[$action . '_on']));
                 }
             }
         }
     }
     unset($parameters[$action . '_from'], $parameters[$action . '_until'], $parameters[$action . '_on']);
     if ($action == 'opened') {
         $action = 'created';
     }
     if ($action == 'resolved') {
         $action = 'updated';
     }
     if ($elements) {
         $parameters[$action . '_on'] = implode('', $elements);
     }
 }
Ejemplo n.º 2
0
 /**
  * Prepare the accepted date values for the API call.
  *
  * @param null $action
  */
 private function sanitizeDateRange($action = null)
 {
     if (is_null($action)) {
         $actions = ['opened', 'resolved', 'closed'];
         foreach ($actions as $action) {
             $this->sanitizeDateRange($action);
         }
         return;
     }
     $elements = [];
     if (isset($this->parameters[$action . '_from']) && isset($this->parameters[$action . '_until'])) {
         array_push($elements, normalizeDateOnly($this->parameters[$action . '_from']));
         array_push($elements, '..');
         array_push($elements, normalizeDateOnly($this->parameters[$action . '_until']));
     } else {
         if (isset($this->parameters[$action . '_from'])) {
             array_push($elements, normalizeDateOnly($this->parameters[$action . '_from']));
             array_push($elements, '..');
         } else {
             if (isset($this->parameters[$action . '_until'])) {
                 array_push($elements, '..');
                 array_push($elements, normalizeDateOnly($this->parameters[$action . '_until']));
             } else {
                 if (isset($this->parameters[$action . '_on'])) {
                     array_push($elements, normalizeDateOnly($this->parameters[$action . '_on']));
                 }
             }
         }
     }
     unset($this->parameters[$action . '_from'], $this->parameters[$action . '_until'], $this->parameters[$action . '_on']);
     if ($elements) {
         $this->setParameter('q', $action . ':' . implode('', $elements));
     }
 }