AbstractProviderFactory.php
1 year ago
Dsn.php
1 year ago
FilteringProvider.php
1 year ago
NullProvider.php
1 year ago
NullProviderFactory.php
1 year ago
ProviderFactoryInterface.php
1 year ago
ProviderInterface.php
1 year ago
TranslationProviderCollection.php
1 year ago
TranslationProviderCollectionFactory.php
1 year ago
index.php
1 year ago
TranslationProviderCollection.php
32 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\Translation\Provider; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\Translation\Exception\InvalidArgumentException; |
| 5 | final class TranslationProviderCollection |
| 6 | { |
| 7 | private $providers; |
| 8 | public function __construct(iterable $providers) |
| 9 | { |
| 10 | $this->providers = \is_array($providers) ? $providers : \iterator_to_array($providers); |
| 11 | } |
| 12 | public function __toString() : string |
| 13 | { |
| 14 | return '[' . \implode(',', \array_keys($this->providers)) . ']'; |
| 15 | } |
| 16 | public function has(string $name) : bool |
| 17 | { |
| 18 | return isset($this->providers[$name]); |
| 19 | } |
| 20 | public function get(string $name) : ProviderInterface |
| 21 | { |
| 22 | if (!$this->has($name)) { |
| 23 | throw new InvalidArgumentException(\sprintf('Provider "%s" not found. Available: "%s".', $name, (string) $this)); |
| 24 | } |
| 25 | return $this->providers[$name]; |
| 26 | } |
| 27 | public function keys() : array |
| 28 | { |
| 29 | return \array_keys($this->providers); |
| 30 | } |
| 31 | } |
| 32 |