X

Create New Item

File Folder

X

Search Results

File "Email.php"

Full path: /home/orbitecv/orbite-school.orbit.et/vendor/kreait/firebase-php/src/Firebase/Value/Email.php
File size: 707 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Edit   Back

<?php

declare(strict_types=1);

namespace Kreait\Firebase\Value;

use Kreait\Firebase\Exception\InvalidArgumentException;
use Stringable;

use function filter_var;

use const FILTER_VALIDATE_EMAIL;

/**
 * @internal
 */
final class Email
{
    /**
     * @var non-empty-string
     */
    public readonly string $value;

    private function __construct(string $value)
    {
        if ($value === '' || !filter_var($value, FILTER_VALIDATE_EMAIL)) {
            throw new InvalidArgumentException('The email address is invalid.');
        }

        $this->value = $value;
    }

    public static function fromString(Stringable|string $value): self
    {
        return new self((string) $value);
    }
}