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

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

- Page: https://pluginprobe.com/plugins/wp-optimize/4.7.0/code/vendor/intervention/httpauth/src/Token/PhpAuthUser.php
- Raw: https://pluginprobe.com/plugins/wp-optimize/4.7.0/raw/vendor/intervention/httpauth/src/Token/PhpAuthUser.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/PhpAuthUser.php#L10-L20`.

```php
<?php

namespace Intervention\HttpAuth\Token;

use Intervention\HttpAuth\Key;

class PhpAuthUser extends NullToken
{
    /**
     * Parsed authentification username
     *
     * @var string
     */
    protected $username;

    /**
     * Parsed authentification password
     *
     * @var string
     */
    protected $password;

    /**
     * Transform current instance to key object
     *
     * @return Key
     */
    public function toKey(): Key
    {
        $key = new Key();
        $key->setProperty('username', $this->username);
        $key->setProperty('password', $this->password);

        return $key;
    }

    /**
     * Parse environment variables and store value in object
     *
     * @return bool "true" if value was found or "false"
     */
    protected function parse(): bool
    {
        if ($username = $this->getArrayValue($_SERVER, 'PHP_AUTH_USER')) {
            $this->username = $username;
            $this->password = array_key_exists('PHP_AUTH_PW', $_SERVER) ? $_SERVER['PHP_AUTH_PW'] : null;

            return true;
        }
        
        return false;
    }
}

```
