# wp-optimize/4.7.0/vendor/intervention/httpauth/src/Token/PhpAuthDigest.php

WP-Optimize – Cache, Compress images, Minify &amp; Clean database to boost page speed &amp; performance, version 4.7.0. 50 lines.

- Page: https://pluginprobe.com/plugins/wp-optimize/4.7.0/code/vendor/intervention/httpauth/src/Token/PhpAuthDigest.php
- Raw: https://pluginprobe.com/plugins/wp-optimize/4.7.0/raw/vendor/intervention/httpauth/src/Token/PhpAuthDigest.php
- Modified: 2021-06-07T22:42:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-optimize/4.7.0/code/vendor/intervention/httpauth/src/Token/PhpAuthDigest.php#L10-L20`.

```php
<?php

namespace Intervention\HttpAuth\Token;

use Intervention\HttpAuth\Key;

class PhpAuthDigest extends NullToken
{
    /**
     * Parsed authentification value
     *
     * @var string
     */
    protected $value;

    /**
     * Transform current instance to key object
     *
     * @return Key
     */
    public function toKey(): Key
    {
        $authKey = new Key();
        preg_match_all('@(\w+)=(?:(?:")([^"]+)"|([^\s,$]+))@', $this->value, $matches, PREG_SET_ORDER);
        foreach ($matches as $m) {
            $key = $m[1];
            $value = $m[2] ? $m[2] : $m[3];
            $authKey->setProperty($key, $value);
        }

        return $authKey;
    }

    /**
     * Parse environment variables and store value in object
     *
     * @return bool "true" if value was found or "false"
     */
    protected function parse(): bool
    {
        if ($value = $this->getArrayValue($_SERVER, 'PHP_AUTH_DIGEST')) {
            $this->value = $value;

            return true;
        }

        return false;
    }
}

```
