@@ -26,31 +26,31 @@ |
||
26 | 26 | */ |
27 | 27 | final class TmpfileStream extends Stream |
28 | 28 | { |
29 | - /** |
|
30 | - * @throws RuntimeException |
|
31 | - */ |
|
32 | - public function __construct() |
|
33 | - { |
|
34 | - parent::__construct(self::createFile()); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * @return resource |
|
39 | - * |
|
40 | - * @throws RuntimeException |
|
41 | - */ |
|
42 | - private static function createFile() |
|
43 | - { |
|
44 | - $dirname = sys_get_temp_dir(); |
|
45 | - if (!is_writable($dirname)) { |
|
46 | - throw new RuntimeException('Temporary files directory is not writable'); |
|
47 | - } |
|
48 | - |
|
49 | - $resource = tmpfile(); |
|
50 | - if (!is_resource($resource)) { |
|
51 | - throw new RuntimeException('Temporary file cannot be created or opened'); |
|
52 | - } |
|
53 | - |
|
54 | - return $resource; |
|
55 | - } |
|
29 | + /** |
|
30 | + * @throws RuntimeException |
|
31 | + */ |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | + parent::__construct(self::createFile()); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * @return resource |
|
39 | + * |
|
40 | + * @throws RuntimeException |
|
41 | + */ |
|
42 | + private static function createFile() |
|
43 | + { |
|
44 | + $dirname = sys_get_temp_dir(); |
|
45 | + if (!is_writable($dirname)) { |
|
46 | + throw new RuntimeException('Temporary files directory is not writable'); |
|
47 | + } |
|
48 | + |
|
49 | + $resource = tmpfile(); |
|
50 | + if (!is_resource($resource)) { |
|
51 | + throw new RuntimeException('Temporary file cannot be created or opened'); |
|
52 | + } |
|
53 | + |
|
54 | + return $resource; |
|
55 | + } |
|
56 | 56 | } |
@@ -17,58 +17,58 @@ |
||
17 | 17 | |
18 | 18 | class ServerRequestFactory implements ServerRequestFactoryInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * @param array<array-key, mixed>|null $serverParams |
|
22 | - * @param array<array-key, mixed>|null $queryParams |
|
23 | - * @param array<array-key, mixed>|null $cookieParams |
|
24 | - * @param array<array-key, mixed>|null $uploadedFiles |
|
25 | - * @param array<array-key, mixed>|null $parsedBody |
|
26 | - * |
|
27 | - * @link http://php.net/manual/en/language.variables.superglobals.php |
|
28 | - * @link https://www.php-fig.org/psr/psr-15/meta/ |
|
29 | - */ |
|
30 | - public static function fromGlobals( |
|
31 | - ?array $serverParams = null, |
|
32 | - ?array $queryParams = null, |
|
33 | - ?array $cookieParams = null, |
|
34 | - ?array $uploadedFiles = null, |
|
35 | - ?array $parsedBody = null |
|
36 | - ): ServerRequestInterface { |
|
37 | - $serverParams ??= $_SERVER; |
|
38 | - $queryParams ??= $_GET; |
|
39 | - $cookieParams ??= $_COOKIE; |
|
40 | - $uploadedFiles ??= $_FILES; |
|
41 | - $parsedBody ??= $_POST; |
|
20 | + /** |
|
21 | + * @param array<array-key, mixed>|null $serverParams |
|
22 | + * @param array<array-key, mixed>|null $queryParams |
|
23 | + * @param array<array-key, mixed>|null $cookieParams |
|
24 | + * @param array<array-key, mixed>|null $uploadedFiles |
|
25 | + * @param array<array-key, mixed>|null $parsedBody |
|
26 | + * |
|
27 | + * @link http://php.net/manual/en/language.variables.superglobals.php |
|
28 | + * @link https://www.php-fig.org/psr/psr-15/meta/ |
|
29 | + */ |
|
30 | + public static function fromGlobals( |
|
31 | + ?array $serverParams = null, |
|
32 | + ?array $queryParams = null, |
|
33 | + ?array $cookieParams = null, |
|
34 | + ?array $uploadedFiles = null, |
|
35 | + ?array $parsedBody = null |
|
36 | + ): ServerRequestInterface { |
|
37 | + $serverParams ??= $_SERVER; |
|
38 | + $queryParams ??= $_GET; |
|
39 | + $cookieParams ??= $_COOKIE; |
|
40 | + $uploadedFiles ??= $_FILES; |
|
41 | + $parsedBody ??= $_POST; |
|
42 | 42 | |
43 | - return new ServerRequest( |
|
44 | - server_request_protocol_version($serverParams), |
|
45 | - server_request_method($serverParams), |
|
46 | - server_request_uri($serverParams), |
|
47 | - server_request_headers($serverParams), |
|
48 | - new PhpInputStream(), |
|
49 | - $serverParams, |
|
50 | - $queryParams, |
|
51 | - $cookieParams, |
|
52 | - server_request_files($uploadedFiles), |
|
53 | - $parsedBody |
|
54 | - ); |
|
55 | - } |
|
43 | + return new ServerRequest( |
|
44 | + server_request_protocol_version($serverParams), |
|
45 | + server_request_method($serverParams), |
|
46 | + server_request_uri($serverParams), |
|
47 | + server_request_headers($serverParams), |
|
48 | + new PhpInputStream(), |
|
49 | + $serverParams, |
|
50 | + $queryParams, |
|
51 | + $cookieParams, |
|
52 | + server_request_files($uploadedFiles), |
|
53 | + $parsedBody |
|
54 | + ); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * {@inheritDoc} |
|
59 | - * |
|
60 | - * @param mixed $uri |
|
61 | - * @param array<array-key, mixed> $serverParams |
|
62 | - */ |
|
63 | - public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface |
|
64 | - { |
|
65 | - return new ServerRequest( |
|
66 | - server_request_protocol_version($serverParams), |
|
67 | - $method, |
|
68 | - $uri, |
|
69 | - server_request_headers($serverParams), |
|
70 | - null, // body |
|
71 | - $serverParams |
|
72 | - ); |
|
73 | - } |
|
57 | + /** |
|
58 | + * {@inheritDoc} |
|
59 | + * |
|
60 | + * @param mixed $uri |
|
61 | + * @param array<array-key, mixed> $serverParams |
|
62 | + */ |
|
63 | + public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface |
|
64 | + { |
|
65 | + return new ServerRequest( |
|
66 | + server_request_protocol_version($serverParams), |
|
67 | + $method, |
|
68 | + $uri, |
|
69 | + server_request_headers($serverParams), |
|
70 | + null, // body |
|
71 | + $serverParams |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | } |
@@ -18,35 +18,35 @@ |
||
18 | 18 | |
19 | 19 | class StreamFactory implements StreamFactoryInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * @inheritDoc |
|
23 | - */ |
|
24 | - public function createStream(string $content = ''): StreamInterface |
|
25 | - { |
|
26 | - $stream = new PhpTempStream(); |
|
27 | - if ($content === '') { |
|
28 | - return $stream; |
|
29 | - } |
|
30 | - |
|
31 | - $stream->write($content); |
|
32 | - $stream->rewind(); |
|
33 | - |
|
34 | - return $stream; |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * @inheritDoc |
|
39 | - */ |
|
40 | - public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface |
|
41 | - { |
|
42 | - return new FileStream($filename, $mode); |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @inheritDoc |
|
47 | - */ |
|
48 | - public function createStreamFromResource($resource): StreamInterface |
|
49 | - { |
|
50 | - return new Stream($resource); |
|
51 | - } |
|
21 | + /** |
|
22 | + * @inheritDoc |
|
23 | + */ |
|
24 | + public function createStream(string $content = ''): StreamInterface |
|
25 | + { |
|
26 | + $stream = new PhpTempStream(); |
|
27 | + if ($content === '') { |
|
28 | + return $stream; |
|
29 | + } |
|
30 | + |
|
31 | + $stream->write($content); |
|
32 | + $stream->rewind(); |
|
33 | + |
|
34 | + return $stream; |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * @inheritDoc |
|
39 | + */ |
|
40 | + public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface |
|
41 | + { |
|
42 | + return new FileStream($filename, $mode); |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @inheritDoc |
|
47 | + */ |
|
48 | + public function createStreamFromResource($resource): StreamInterface |
|
49 | + { |
|
50 | + return new Stream($resource); |
|
51 | + } |
|
52 | 52 | } |
@@ -16,11 +16,11 @@ |
||
16 | 16 | |
17 | 17 | class UriFactory implements UriFactoryInterface |
18 | 18 | { |
19 | - /** |
|
20 | - * @inheritDoc |
|
21 | - */ |
|
22 | - public function createUri(string $uri = ''): UriInterface |
|
23 | - { |
|
24 | - return new Uri($uri); |
|
25 | - } |
|
19 | + /** |
|
20 | + * @inheritDoc |
|
21 | + */ |
|
22 | + public function createUri(string $uri = ''): UriInterface |
|
23 | + { |
|
24 | + return new Uri($uri); |
|
25 | + } |
|
26 | 26 | } |
@@ -20,40 +20,40 @@ |
||
20 | 20 | */ |
21 | 21 | final class Port implements ComponentInterface |
22 | 22 | { |
23 | - private const MIN_VALUE = 1; |
|
24 | - private const MAX_VALUE = (2 ** 16) - 1; |
|
25 | - |
|
26 | - private ?int $value = null; |
|
27 | - |
|
28 | - /** |
|
29 | - * @param mixed $value |
|
30 | - * |
|
31 | - * @throws InvalidArgumentException |
|
32 | - */ |
|
33 | - public function __construct($value) |
|
34 | - { |
|
35 | - if ($value === null) { |
|
36 | - return; |
|
37 | - } |
|
38 | - |
|
39 | - if (!is_int($value)) { |
|
40 | - throw new InvalidArgumentException('URI component "port" must be an integer'); |
|
41 | - } |
|
42 | - |
|
43 | - if (!($value >= self::MIN_VALUE && $value <= self::MAX_VALUE)) { |
|
44 | - throw new InvalidArgumentException('Invalid URI component "port"'); |
|
45 | - } |
|
46 | - |
|
47 | - $this->value = $value; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * {@inheritdoc} |
|
52 | - * |
|
53 | - * @return int|null |
|
54 | - */ |
|
55 | - public function getValue(): ?int |
|
56 | - { |
|
57 | - return $this->value; |
|
58 | - } |
|
23 | + private const MIN_VALUE = 1; |
|
24 | + private const MAX_VALUE = (2 ** 16) - 1; |
|
25 | + |
|
26 | + private ?int $value = null; |
|
27 | + |
|
28 | + /** |
|
29 | + * @param mixed $value |
|
30 | + * |
|
31 | + * @throws InvalidArgumentException |
|
32 | + */ |
|
33 | + public function __construct($value) |
|
34 | + { |
|
35 | + if ($value === null) { |
|
36 | + return; |
|
37 | + } |
|
38 | + |
|
39 | + if (!is_int($value)) { |
|
40 | + throw new InvalidArgumentException('URI component "port" must be an integer'); |
|
41 | + } |
|
42 | + |
|
43 | + if (!($value >= self::MIN_VALUE && $value <= self::MAX_VALUE)) { |
|
44 | + throw new InvalidArgumentException('Invalid URI component "port"'); |
|
45 | + } |
|
46 | + |
|
47 | + $this->value = $value; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * {@inheritdoc} |
|
52 | + * |
|
53 | + * @return int|null |
|
54 | + */ |
|
55 | + public function getValue(): ?int |
|
56 | + { |
|
57 | + return $this->value; |
|
58 | + } |
|
59 | 59 | } |
@@ -22,43 +22,43 @@ |
||
22 | 22 | */ |
23 | 23 | final class Query implements ComponentInterface |
24 | 24 | { |
25 | - // phpcs:ignore Generic.Files.LineLength |
|
26 | - private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x3f-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u'; |
|
25 | + // phpcs:ignore Generic.Files.LineLength |
|
26 | + private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x3f-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u'; |
|
27 | 27 | |
28 | - private string $value = ''; |
|
28 | + private string $value = ''; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param mixed $value |
|
32 | - * |
|
33 | - * @throws InvalidArgumentException |
|
34 | - */ |
|
35 | - public function __construct($value) |
|
36 | - { |
|
37 | - if ($value === '') { |
|
38 | - return; |
|
39 | - } |
|
30 | + /** |
|
31 | + * @param mixed $value |
|
32 | + * |
|
33 | + * @throws InvalidArgumentException |
|
34 | + */ |
|
35 | + public function __construct($value) |
|
36 | + { |
|
37 | + if ($value === '') { |
|
38 | + return; |
|
39 | + } |
|
40 | 40 | |
41 | - if (!is_string($value)) { |
|
42 | - throw new InvalidArgumentException('URI component "query" must be a string'); |
|
43 | - } |
|
41 | + if (!is_string($value)) { |
|
42 | + throw new InvalidArgumentException('URI component "query" must be a string'); |
|
43 | + } |
|
44 | 44 | |
45 | - $this->value = (string) preg_replace_callback( |
|
46 | - self::NORMALIZATION_REGEX, |
|
47 | - static fn(array $matches): string => ( |
|
48 | - /** @var array{0: string, 1?: string} $matches */ |
|
49 | - isset($matches[1]) ? rawurlencode($matches[1]) : $matches[0] |
|
50 | - ), |
|
51 | - $value, |
|
52 | - ); |
|
53 | - } |
|
45 | + $this->value = (string) preg_replace_callback( |
|
46 | + self::NORMALIZATION_REGEX, |
|
47 | + static fn(array $matches): string => ( |
|
48 | + /** @var array{0: string, 1?: string} $matches */ |
|
49 | + isset($matches[1]) ? rawurlencode($matches[1]) : $matches[0] |
|
50 | + ), |
|
51 | + $value, |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * {@inheritdoc} |
|
57 | - * |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getValue(): string |
|
61 | - { |
|
62 | - return $this->value; |
|
63 | - } |
|
55 | + /** |
|
56 | + * {@inheritdoc} |
|
57 | + * |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getValue(): string |
|
61 | + { |
|
62 | + return $this->value; |
|
63 | + } |
|
64 | 64 | } |
@@ -22,43 +22,43 @@ |
||
22 | 22 | */ |
23 | 23 | final class Fragment implements ComponentInterface |
24 | 24 | { |
25 | - // phpcs:ignore Generic.Files.LineLength |
|
26 | - private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x3f-\x5a\x5f\x61-\x7a\x7e])*|(.?)/u'; |
|
25 | + // phpcs:ignore Generic.Files.LineLength |
|
26 | + private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x3f-\x5a\x5f\x61-\x7a\x7e])*|(.?)/u'; |
|
27 | 27 | |
28 | - private string $value = ''; |
|
28 | + private string $value = ''; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param mixed $value |
|
32 | - * |
|
33 | - * @throws InvalidArgumentException |
|
34 | - */ |
|
35 | - public function __construct($value) |
|
36 | - { |
|
37 | - if ($value === '') { |
|
38 | - return; |
|
39 | - } |
|
30 | + /** |
|
31 | + * @param mixed $value |
|
32 | + * |
|
33 | + * @throws InvalidArgumentException |
|
34 | + */ |
|
35 | + public function __construct($value) |
|
36 | + { |
|
37 | + if ($value === '') { |
|
38 | + return; |
|
39 | + } |
|
40 | 40 | |
41 | - if (!is_string($value)) { |
|
42 | - throw new InvalidArgumentException('URI component "fragment" must be a string'); |
|
43 | - } |
|
41 | + if (!is_string($value)) { |
|
42 | + throw new InvalidArgumentException('URI component "fragment" must be a string'); |
|
43 | + } |
|
44 | 44 | |
45 | - $this->value = (string) preg_replace_callback( |
|
46 | - self::NORMALIZATION_REGEX, |
|
47 | - static fn(array $matches): string => ( |
|
48 | - /** @var array{0: string, 1?: string} $matches */ |
|
49 | - isset($matches[1]) ? rawurlencode($matches[1]) : $matches[0] |
|
50 | - ), |
|
51 | - $value, |
|
52 | - ); |
|
53 | - } |
|
45 | + $this->value = (string) preg_replace_callback( |
|
46 | + self::NORMALIZATION_REGEX, |
|
47 | + static fn(array $matches): string => ( |
|
48 | + /** @var array{0: string, 1?: string} $matches */ |
|
49 | + isset($matches[1]) ? rawurlencode($matches[1]) : $matches[0] |
|
50 | + ), |
|
51 | + $value, |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * {@inheritdoc} |
|
57 | - * |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function getValue(): string |
|
61 | - { |
|
62 | - return $this->value; |
|
63 | - } |
|
55 | + /** |
|
56 | + * {@inheritdoc} |
|
57 | + * |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function getValue(): string |
|
61 | + { |
|
62 | + return $this->value; |
|
63 | + } |
|
64 | 64 | } |
@@ -18,37 +18,37 @@ |
||
18 | 18 | */ |
19 | 19 | final class UserInfo implements ComponentInterface |
20 | 20 | { |
21 | - private User $user; |
|
22 | - private ?Password $password = null; |
|
23 | - |
|
24 | - /** |
|
25 | - * @param mixed $user |
|
26 | - * @param mixed $password |
|
27 | - * |
|
28 | - * @throws InvalidArgumentException |
|
29 | - */ |
|
30 | - public function __construct($user, $password = null) |
|
31 | - { |
|
32 | - $this->user = User::create($user); |
|
33 | - |
|
34 | - if ($password !== null) { |
|
35 | - $this->password = Password::create($password); |
|
36 | - } |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * {@inheritdoc} |
|
41 | - * |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function getValue(): string |
|
45 | - { |
|
46 | - $value = $this->user->getValue(); |
|
47 | - |
|
48 | - if ($this->password !== null) { |
|
49 | - $value .= ':' . $this->password->getValue(); |
|
50 | - } |
|
51 | - |
|
52 | - return $value; |
|
53 | - } |
|
21 | + private User $user; |
|
22 | + private ?Password $password = null; |
|
23 | + |
|
24 | + /** |
|
25 | + * @param mixed $user |
|
26 | + * @param mixed $password |
|
27 | + * |
|
28 | + * @throws InvalidArgumentException |
|
29 | + */ |
|
30 | + public function __construct($user, $password = null) |
|
31 | + { |
|
32 | + $this->user = User::create($user); |
|
33 | + |
|
34 | + if ($password !== null) { |
|
35 | + $this->password = Password::create($password); |
|
36 | + } |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * {@inheritdoc} |
|
41 | + * |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function getValue(): string |
|
45 | + { |
|
46 | + $value = $this->user->getValue(); |
|
47 | + |
|
48 | + if ($this->password !== null) { |
|
49 | + $value .= ':' . $this->password->getValue(); |
|
50 | + } |
|
51 | + |
|
52 | + return $value; |
|
53 | + } |
|
54 | 54 | } |
@@ -22,57 +22,57 @@ |
||
22 | 22 | */ |
23 | 23 | final class User implements ComponentInterface |
24 | 24 | { |
25 | - // phpcs:ignore Generic.Files.LineLength |
|
26 | - private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x2e\x30-\x39\x3b\x3d\x41-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u'; |
|
25 | + // phpcs:ignore Generic.Files.LineLength |
|
26 | + private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x2e\x30-\x39\x3b\x3d\x41-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u'; |
|
27 | 27 | |
28 | - private string $value = ''; |
|
28 | + private string $value = ''; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param mixed $value |
|
32 | - * |
|
33 | - * @throws InvalidArgumentException |
|
34 | - */ |
|
35 | - public function __construct($value) |
|
36 | - { |
|
37 | - if ($value === '') { |
|
38 | - return; |
|
39 | - } |
|
30 | + /** |
|
31 | + * @param mixed $value |
|
32 | + * |
|
33 | + * @throws InvalidArgumentException |
|
34 | + */ |
|
35 | + public function __construct($value) |
|
36 | + { |
|
37 | + if ($value === '') { |
|
38 | + return; |
|
39 | + } |
|
40 | 40 | |
41 | - if (!is_string($value)) { |
|
42 | - throw new InvalidArgumentException('URI component "user" must be a string'); |
|
43 | - } |
|
41 | + if (!is_string($value)) { |
|
42 | + throw new InvalidArgumentException('URI component "user" must be a string'); |
|
43 | + } |
|
44 | 44 | |
45 | - $this->value = (string) preg_replace_callback( |
|
46 | - self::NORMALIZATION_REGEX, |
|
47 | - static fn(array $matches): string => ( |
|
48 | - /** @var array{0: string, 1?: string} $matches */ |
|
49 | - isset($matches[1]) ? rawurlencode($matches[1]) : $matches[0] |
|
50 | - ), |
|
51 | - $value, |
|
52 | - ); |
|
53 | - } |
|
45 | + $this->value = (string) preg_replace_callback( |
|
46 | + self::NORMALIZATION_REGEX, |
|
47 | + static fn(array $matches): string => ( |
|
48 | + /** @var array{0: string, 1?: string} $matches */ |
|
49 | + isset($matches[1]) ? rawurlencode($matches[1]) : $matches[0] |
|
50 | + ), |
|
51 | + $value, |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param mixed $user |
|
57 | - * |
|
58 | - * @throws InvalidArgumentException |
|
59 | - */ |
|
60 | - public static function create($user): User |
|
61 | - { |
|
62 | - if ($user instanceof User) { |
|
63 | - return $user; |
|
64 | - } |
|
55 | + /** |
|
56 | + * @param mixed $user |
|
57 | + * |
|
58 | + * @throws InvalidArgumentException |
|
59 | + */ |
|
60 | + public static function create($user): User |
|
61 | + { |
|
62 | + if ($user instanceof User) { |
|
63 | + return $user; |
|
64 | + } |
|
65 | 65 | |
66 | - return new User($user); |
|
67 | - } |
|
66 | + return new User($user); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * {@inheritdoc} |
|
71 | - * |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function getValue(): string |
|
75 | - { |
|
76 | - return $this->value; |
|
77 | - } |
|
69 | + /** |
|
70 | + * {@inheritdoc} |
|
71 | + * |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function getValue(): string |
|
75 | + { |
|
76 | + return $this->value; |
|
77 | + } |
|
78 | 78 | } |