HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: root (0)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //var/www/intranet.kauko.lt/wp-content/plugins/authldap/src/Value/Username.php
<?php

declare(strict_types=1);

namespace Org_Heigl\AuthLdap\Value;

use InvalidArgumentException;

final class Username
{
	private string $username;
	private function __construct(string $username)
	{
		$this->username = $username;
	}

	/**
	 * @param mixed $username
	 */
	public static function fromMixed($username): self
	{
		if (! is_string($username)) {
			throw new InvalidArgumentException('No valid username provided');
		}
		if ($username === '') {
			throw new InvalidArgumentException('No username provided');
		}

		return new self($username);
	}

	public function __toString(): string
	{
		return $this->username;
	}
}