for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of the G.L.S.R. Apps package.
*
* (c) Dev-Int Création <[email protected]>.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Administration\Domain\Settings\Model\VO;
final class Currency
{
public const CURRENCY = ['euro'];
public const SYMBOL = ['€'];
private string $currency;
private string $symbol;
public function __construct(string $currency)
$this->currency = self::isCurrency($currency);
$this->symbol = self::isSymbol($this->currency);
}
public static function fromString(string $currency): self
return new self($currency);
public function getValue(): string
return $this->currency;
public function symbol(): string
return $this->symbol;
private static function isCurrency(string $currency): string
if (!\in_array(\strtolower($currency), self::CURRENCY, true)) {
throw new InvalidCurrency();
return \strtolower($currency);
private static function isSymbol(string $currency): string
return self::SYMBOL[\array_search($currency, self::CURRENCY, true)];