| Total Complexity | 7 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 11 | class TraefikPassword implements LazyExportableOption, FromEnvLazyFactory |
||
| 12 | { |
||
| 13 | const TRAEFIK_UI_PASSWORD = 'TRAEFIK_UI_PASSWORD'; |
||
| 14 | const OPTION_NAME = 'traefik-ui-password'; |
||
| 15 | const REGEX = '/^[a-zA-Z0-9_@#%?&*+=!-]+$/'; |
||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | private $value; |
||
| 20 | |||
| 21 | public function __construct(string $value) |
||
| 22 | { |
||
| 23 | Assertion::notEmpty($value, "The Traefik Ui password is empty"); |
||
| 24 | Assertion::regex( |
||
| 25 | $value, |
||
| 26 | self::REGEX, |
||
| 27 | "The Traefik Ui password does not contain only alphanumeric characters and _@#%?&*+=!-" |
||
| 28 | ); |
||
| 29 | $this->value = $value; |
||
| 30 | } |
||
| 31 | |||
| 32 | public static function fromString(string $value): self |
||
| 33 | { |
||
| 34 | return new self($value); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param Env $env |
||
| 39 | * @return LazyEnvironmentValue|self |
||
| 40 | */ |
||
| 41 | public static function fromEnv(Env $env): LazyEnvironmentValue |
||
| 42 | { |
||
| 43 | return new self($env->get(self::TRAEFIK_UI_PASSWORD, "")); |
||
|
|
|||
| 44 | } |
||
| 45 | |||
| 46 | public static function toEnv(string $value, Env $env): void |
||
| 49 | } |
||
| 50 | |||
| 51 | public static function optionName(): string |
||
| 52 | { |
||
| 53 | return self::OPTION_NAME; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function toString(): string |
||
| 57 | { |
||
| 58 | return $this->value; |
||
| 59 | } |
||
| 60 | |||
| 61 | public function __toString() |
||
| 64 | } |
||
| 65 | } |