| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php declare( strict_types=1 ); |
||
| 8 | class Message { |
||
| 9 | /** @var string */ |
||
| 10 | private $key; |
||
| 11 | /** @var string */ |
||
| 12 | private $value; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @param string $key |
||
| 16 | */ |
||
| 17 | public function __construct( string $key ) { |
||
| 18 | $this->key = $key; |
||
| 19 | $this->value = Config::getInstance()->get( $key ); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param string[] $args |
||
| 24 | * @return self |
||
| 25 | */ |
||
| 26 | public function params( $args ) : self { |
||
| 27 | $this->value = strtr( $this->value, $args ); |
||
| 28 | return $this; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @return string |
||
| 33 | */ |
||
| 34 | public function text() : string { |
||
| 35 | $this->parsePlurals(); |
||
| 36 | return $this->value; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Replace {{$plur|<amount>|sing|plur}} |
||
| 41 | */ |
||
| 42 | protected function parsePlurals() { |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |