Extract cookies values from a request.

@param  string  $value A Cookie header value.
@return array           The cookies values.
357887
public static function toArray($value)
    {
        $data = [];

        $cookies = $value ? explode(';', $value) : [];
        foreach ($cookies as $cookie) {
            list($name, $value) = explode('=', $cookie);
            $name = trim($name);
            $value = urldecode($value);
            if (!isset($data[$name])) {
                $data[$name] = $value;
            }
        }
        return $data;
    }
1218024
public function getValues() {

        $cookies = [];

        try {

            foreach ( $this->cookies as $name => $cookie ) {

                $cookies[$name] = $cookie->getValue();

            }

        } catch (CookieException $ce) {

            throw $ce;

        }

        return $cookies;

    }
1104365
public function filter($value)
    {
        if (null === $value) {
            return null;
        }
        $this->checkValueIsArrayOrThrowException($value);

        $return = [];
        foreach ($value as $header => $condition) {
            $return[$header] = $this->conditionFilter->filter($condition);
        }

        return $return;
    }
695888
public function transform($value)
    {
        $sites = array();
        if (!empty($value)) {
            foreach ($value as $associatedSite) {
                $sites[] = $associatedSite['siteId'];
            }
        }
        return $sites;
    }
1012047
public function apply(Value $value): array
    {
        if ($value->isEmpty()) {
            return $this->filtered(new Token(null));
        }

        $value = $value->value();
        if (strtolower(trim(substr($value, 0, 7))) === 'bearer') {
            return $this->filtered(new Token(substr($value, 7)));
        }

        return $this->filtered(new Token($value));
    }
628975
public static function getValueAsList($value) {
		$tokens = token_get_all('<?php '.$value);

		$resultArray = array();
		
		// Le's find all the strings, and let's put each string in the table.
		foreach ($tokens as $token) {
			if ($token[0] == T_CONSTANT_ENCAPSED_STRING) {
				$resultArray[] = substr($token[1], 1, strlen($token[1])-2) ;
			}
		}

		return  $resultArray;
	}
500355
public function cookies($request)
    {
        $headers = $response->headers();
        if (!isset($headers['Set-Cookie'])) {
            return [];
        }
        $setCookies = [];
        foreach ($headers['Set-Cookie'] as $setCookieHeader) {
            $setCookie = Cookie::fromString($setCookieHeader);
            if (!$setCookie->domain()) {
                $setCookie->domain($request->hostname());
            }
            if (strpos($setCookie->path(), '/') !== 0) {
                $setCookie->path($this->_pathFrom($request));
            }
            $setCookies[] = $setCookie;
        }
        return $setCookies;
    }
1254164
protected function _parseCookies($header) {
		$cookies = array_map('trim', array_filter(explode('; ', $header)));
		foreach ($cookies as $cookie) {
			list($name, $value) = array_map('urldecode', explode('=', $cookie, 2)) + ['',''];
			$this->cookies($name, $value);
		}
	}
788406
public function request($value)
    {
        if (!isset($this->request[$value])) {
            return false;
        } else {
            return $this->request[$value];
        }
    }
454265
protected function receiveTokenFieldValueFromRequest($value = null)
    {
        $requestQueryParameter = $this->getRequest()->getQueryParams();
        $requestBody           = $this->getRequest()->getParsedBody();
        $fieldname             = $this->getFieldnameToken();

        if (true === isset($requestQueryParameter[$fieldname])) {
            $value = $requestQueryParameter[$fieldname];
        } elseif (true === isset($requestBody[$fieldname])) {
            $value = $requestBody[$fieldname];
        }

        return $value;
    }
801077
public function filter($value)
    {
        if (!$value instanceof User) {
            return array();
        }

        $info = $value->getInfo();

        return array(
            'id' => $value->getId(),
            'name' => $info->displayName,
            'image' => $info->image ? $info->image->uri : '',
            'email' => $info->email,
        );
    }
1236706
public final function cookie(string $name, string $value = null)
    {
        return ($value === null) ? $this->getCookie($name) : $this->setCookie($name, $value);
    }
965342
private function createCookieWithValue($value)
    {
        return new Cookie(
            $this->cookieSettings->getName(),
            $value,
            $this->cookieSettings->getExpiresTime(),
            $this->cookieSettings->getPath(),
            $this->cookieSettings->getDomain(),
            $this->cookieSettings->isSecure(),
            $this->cookieSettings->isHttpOnly()
        );
    }
360433
protected function extractAdUsername(Request $request, $value)
    {
        $pattern = "/((?m)(?<=\b".self::COOKIE_FIELD_NAME."=)[^;]*)/i";
        preg_match($pattern, $value, $matches);

        if ($matches) {
            $request->attributes->set(self::CONFIGURATION_PARAMETER_USER_ID, $matches[0]);

            return $matches[0];
        }

        return $value;
    }
1310593
public function cookie($key = '', $value = '', $options = null)
    {
        $defaultOptions = [
            'prefix' => '',
            'expire' => 86400,
            'path' => '/',
            'secure' => false,
            'httponly' => false,
        ];

        if (!is_null($options)) {
            if (is_numeric($options)) {
                $options = ['expire' => $options];
            } elseif (is_string($options)) {
                parse_str($options, $options);
            }

            $options = array_merge($defaultOptions, array_change_key_case($options));
        }

        if (!empty($options['httponly'])) {
            ini_set('session.cookie_httponly', 1);
        }

        if (is_null($key)) {
            if (empty($_COOKIE)) {
                return null;
            }

            $prefix = empty($value) ? $options['prefix'] : $value;
            if (!empty($prefix)) {
                foreach ($_COOKIE as $key => $val) {
                    if (0 === stripos($key, $prefix)) {
                        setcookie($key, '', time() - 3600, $options['path'], $options['domain'], $options['secure'], $options['httponly']);
                        unset($_COOKIE[$key]);
                    }
                }
            }

            return null;
        } elseif ('' === $key) {
            // Get All Cookie
            return $_COOKIE;
        }

        $key = $options['prefix'] . str_replace('.', '_', $key);
        if ('' === $value) {
            if (isset($_COOKIE[$key])) {
                $value = $_COOKIE[$key];
                if (0 === strpos($value, 'kotori:')) {
                    $value = substr($value, 6);
                    return array_map('urldecode', json_decode(MAGIC_QUOTES_GPC ? stripslashes($value) : $value, true));
                } else {
                    return $value;
                }
            } else {
                return null;
            }
        } else {
            if (is_null($value)) {
                setcookie($key, '', time() - 3600, $options['path'], $options['domain'], $options['secure'], $options['httponly']);
                unset($_COOKIE[$key]); // Delete Cookie
            } else {
                // Set Cookie
                if (is_array($value)) {
                    $value = 'kotori:' . json_encode(array_map('urlencode', $value));
                }

                $expire = !empty($options['expire']) ? time() + intval($options['expire']) : 0;
                setcookie($key, $value, $expire, $options['path'], $options['domain'], $options['secure'], $options['httponly']);
                $_COOKIE[$key] = $value;
            }
        }

        return null;
    }
1075679
public function getUserValue($value)
    {
        if (! is_array($value)) {
            if ('' == $value) {
                $value = [];
            } else {
                $value = explode($this->getSeparator(), $value);
            }
        }

        return $value;
    }
477896
private function parseCookies($str) {  
	    
	    if(false === is_string($str)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($str)), E_USER_ERROR);
		}

	    $jar 	 = [];
		$headers = explode("\n", trim($str));

		foreach($headers as $header) {

			if(preg_match('/^set-cookie: /i', $header)) {
				
				$cookie = [];

				//Match name and value
				preg_match('/^set-cookie: ([^=]+)=([^;]+)/i', $header, $match);

				if(count($match) === 3) {
					
					$cookie['name']  = $match[1];
					$cookie['value'] = $match[2];
				
					//Match expires
					$cookie['expires'] = null;

					preg_match('/; expires=([^;]+)/i', $header, $match);

					if(count($match) === 2) {
						$cookie['expires'] = strtotime(urldecode(trim($match[1])));
					}

					//Match domain
					$cookie['domain'] = null;

					preg_match('/; domain=([^;]+)/i', $header, $match);

					if(count($match) === 2) {
						$cookie['domain'] = urldecode(trim($match[1]));
					}

					//Match secure
					$cookie['secure'] = false;

					preg_match('/; secure/i', $header, $match);

					if(count($match) === 1) {
						$cookie['secure'] = true;
					}

					//Match httponly
					$cookie['httponly'] = false;

					preg_match('/; httponly/i', $header, $match);

					if(count($match) === 1) {
						$cookie['httponly'] = true;
					}

					//Add cookie to the jar
					if(count($cookie) > 0) {
						$jar[] = $cookie;
					}
				}
			}
		}

		return $jar;
	}