Skip to content

Commit

Permalink
use readonly classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmajor committed Mar 2, 2024
1 parent a81ba0c commit cb19421
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions dev/Currencies/CurrenciesOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Major\Fluent\Formatters\Number\Locale\Currency;
use Psl\Dict;

final class CurrenciesOptimizer
final readonly class CurrenciesOptimizer
{
public function __construct(
/** @var array<string, Currency> */
private readonly array $und,
private array $und,
) { }

/**
Expand Down
14 changes: 7 additions & 7 deletions src/Formatters/Number/Locale/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
/**
* @internal
*/
final class Currency
final readonly class Currency
{
public readonly string $name;
public string $name;

public readonly string $symbol;
public string $symbol;

public readonly string $narrow;
public string $narrow;

/** @var ?non-empty-array<string, string> */
public readonly ?array $plurals;
public ?array $plurals;

/**
* @param string|non-empty-array<string, string>|null $plurals
*/
public function __construct(
public readonly string $code,
public string $code,
?string $name = null,
?string $symbol = null,
?string $narrow = null,
string|array|null $plurals = null,
public readonly int $minorUnits = 2,
public int $minorUnits = 2,
) {
$this->name = $name ?? $code;
$this->symbol = $symbol ?? $code;
Expand Down
16 changes: 8 additions & 8 deletions src/Formatters/Number/Locale/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
/**
* @internal
*/
final class Locale
final readonly class Locale
{
public function __construct(
public readonly string $system = 'latn',
public readonly string $decimal = '#,##0.###',
public readonly string $percent = '#,##0%',
public readonly string $currency = "#,##0.00\u{A0}¤",
public readonly int $grouping = 1,
public string $system = 'latn',
public string $decimal = '#,##0.###',
public string $percent = '#,##0%',
public string $currency = "#,##0.00\u{A0}¤",
public int $grouping = 1,
/** @var array{string, string, string, string} */
public readonly array $symbols = ['.', ',', '-', '%'],
public array $symbols = ['.', ',', '-', '%'],
/** @var array<string, string> */
public readonly array $unitPatterns = [],
public array $unitPatterns = [],
) { }

public function symbol(string $symbol): string
Expand Down
8 changes: 4 additions & 4 deletions src/Formatters/Number/Locale/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
/**
* @internal
*/
final class Unit
final readonly class Unit
{
/** @var array<string, string> */
public readonly array $longPlurals;
public array $longPlurals;

/** @var array<string, string> */
public readonly array $shortPlurals;
public array $shortPlurals;

/** @var array<string, string> */
public readonly array $narrowPlurals;
public array $narrowPlurals;

/**
* @param string|array<string, string> $longPlurals
Expand Down

0 comments on commit cb19421

Please sign in to comment.