PluginProbe
Metricool – Social media and site statistics / 2.1.1
Metricool – Social media and site statistics v2.1.1
2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
metricool / vendor / _scoped / symfony / translation / Provider / TranslationProviderCollection.php

TranslationProviderCollection.php in Metricool – Social media and site statistics 2.1.1, at vendor/_scoped/symfony/translation/Provider/TranslationProviderCollection.php

50 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace Metricool\Vendor\Symfony\Component\Translation\Provider;
12
13 use Metricool\Vendor\Symfony\Component\Translation\Exception\InvalidArgumentException;
14 /**
15 * @author Mathieu Santostefano <[email protected]>
16 */
17 final class TranslationProviderCollection
18 {
19 /**
20 * @var array<string, ProviderInterface>
21 */
22 private $providers;
23 /**
24 * @param array<string, ProviderInterface> $providers
25 */
26 public function __construct(iterable $providers)
27 {
28 $this->providers = \is_array($providers) ? $providers : iterator_to_array($providers);
29 }
30 public function __toString(): string
31 {
32 return '[' . implode(',', array_keys($this->providers)) . ']';
33 }
34 public function has(string $name): bool
35 {
36 return isset($this->providers[$name]);
37 }
38 public function get(string $name): ProviderInterface
39 {
40 if (!$this->has($name)) {
41 throw new InvalidArgumentException(sprintf('Provider "%s" not found. Available: "%s".', $name, (string) $this));
42 }
43 return $this->providers[$name];
44 }
45 public function keys(): array
46 {
47 return array_keys($this->providers);
48 }
49 }
50