Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
9 / 9 |
Locale | |
100.00% |
1 / 1 |
|
100.00% |
4 / 4 |
8 | |
100.00% |
9 / 9 |
__construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
4 / 4 |
|||
load | |
100.00% |
1 / 1 |
2 | |
100.00% |
2 / 2 |
|||
process | |
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
|||
setLoaderFormat | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
<?php | |
declare(strict_types=1); | |
namespace I18Next; | |
use atk4\core\Exception; | |
use I18Next\Locale\Processor; | |
use I18Next\Locale\Translations; | |
/** | |
* @internal | |
*/ | |
final class Locale | |
{ | |
/** @var string */ | |
private $code; | |
private $processor; | |
private $translations; | |
public function __construct(string $code) | |
{ | |
$this->code = $code; | |
$this->translations = new Translations(); | |
$this->processor = new Processor($this->translations); | |
} | |
/** | |
* @param string $path | |
* @param bool $use_filename_as_namespace | |
* @param string|null ...$namespace_priority | |
* | |
* @throws Exception | |
*/ | |
public function load(string $path, bool $use_filename_as_namespace, ?string ...$namespace_priority): void | |
{ | |
$this->translations->load($path.DIRECTORY_SEPARATOR.$this->code, $use_filename_as_namespace, ...$namespace_priority); | |
} | |
public function process(string $key, ?array $parameters = null, ?string $context = null): ?string | |
{ | |
return $this->processor->process($key, $parameters, $context); | |
} | |
public function setLoaderFormat(string $format): void | |
{ | |
$this->translations->setLoaderFormat($format); | |
} | |
} |