src/Viserio/Component/Cookie/ResponseCookies.php
protected static function fromStringCookie(string $string): CookieContract
    {
        $rawAttributes = self::splitOnAttributeDelimiter($string);

        [$cookieName, $cookieValue] = self::splitCookiePair(\array_shift($rawAttributes));

        $cookie = new SetCookie($cookieName);

        if (null !== $cookieValue) {
            $cookie = $cookie->withValue($cookieValue);
        }

        foreach ($rawAttributes as $value) {
            $rawAttributePair = \explode('=', $value, 2);
            $attributeKey     = $rawAttributePair[0];
            $attributeValue   = \count($rawAttributePair) > 1 ? $rawAttributePair[1] : null;
            $attributeKey     = \mb_strtolower($attributeKey);

            switch ($attributeKey) {
                case 'expires':
                    $cookie = $cookie->withExpires(new Chronos($attributeValue));

                    break;
                case 'max-age':
                    $age    = \is_numeric($attributeValue) ? (int) $attributeValue : null;
                    $cookie = $cookie->withMaxAge($age);

                    break;
                case 'domain':
                    $cookie = $cookie->withDomain($attributeValue);

                    break;
                case 'path':
                    $cookie = $cookie->withPath($attributeValue ?? '/');

                    break;
                case 'secure':
                    $cookie = $cookie->withSecure(true);

                    break;
                case 'httponly':
                    $cookie = $cookie->withHttpOnly(true);

                    break;
                case 'samesite':
                    $cookie = $cookie->withSameSite($attributeValue);

                    break;
            }
        }

        return $cookie;
    }
protected static function fromStringCookie(string $string): CookieContract
    {
        $rawAttributes = self::splitOnAttributeDelimiter($string);

        [$cookieName, $cookieValue] = self::splitCookiePair(\array_shift($rawAttributes));

        $cookie = new SetCookie($cookieName);

        if (null !== $cookieValue) {
            $cookie = $cookie->withValue($cookieValue);
        }

        foreach ($rawAttributes as $value) {
            $rawAttributePair = \explode('=', $value, 2);
            $attributeKey     = $rawAttributePair[0];
            $attributeValue   = \count($rawAttributePair) > 1 ? $rawAttributePair[1] : null;
            $attributeKey     = \mb_strtolower($attributeKey);

            switch ($attributeKey) {
                case 'expires':
                    $cookie = $cookie->withExpires(new Chronos($attributeValue));

                    break;
                case 'max-age':
                    $age    = \is_numeric($attributeValue) ? (int) $attributeValue : null;
                    $cookie = $cookie->withMaxAge($age);

                    break;
                case 'domain':
                    $cookie = $cookie->withDomain($attributeValue);

                    break;
                case 'path':
                    $cookie = $cookie->withPath($attributeValue ?? '/');

                    break;
                case 'secure':
                    $cookie = $cookie->withSecure(true);

                    break;
                case 'httponly':
                    $cookie = $cookie->withHttpOnly(true);

                    break;
                case 'samesite':
                    $cookie = $cookie->withSameSite($attributeValue);

                    break;
            }
        }

        return $cookie;
    }
Creates a Cookie instance from a Set-Cookie header value.

@param string $string

@return \Viserio\Component\Contract\Cookie\Cookie