Exemple #1
0
 /**
  * @param array $data Array of cookie data provided by a Cookie parser
  */
 public function __construct(array $data = array())
 {
     $this->data = __puzzle_array_replace(self::$defaults, $data);
     // Extract the Expires value and turn it into a UNIX timestamp if needed
     if (!$this->getExpires() && $this->getMaxAge()) {
         // Calculate the Expires date
         $this->setExpires(time() + $this->getMaxAge());
     } elseif ($this->getExpires() && !is_numeric($this->getExpires())) {
         $this->setExpires($this->getExpires());
     }
 }
Exemple #2
0
 private function configureDefaults($config)
 {
     if (!isset($config['defaults'])) {
         $this->defaults = $this->getDefaultOptions();
     } else {
         $this->defaults = __puzzle_array_replace($this->getDefaultOptions(), $config['defaults']);
     }
     // Add the default user-agent header
     if (!isset($this->defaults['headers'])) {
         $this->defaults['headers'] = array('User-Agent' => self::getDefaultUserAgent());
     } else {
         $h = array_change_key_case($this->defaults['headers']);
         if (!isset($h['user-agent'])) {
             // Add the User-Agent header if one was not already set
             $this->defaults['headers']['User-Agent'] = self::getDefaultUserAgent();
         }
     }
 }