AbstractProviderFactory.php
1 month ago
Dsn.php
1 month ago
FilteringProvider.php
1 month ago
NullProvider.php
2 years ago
NullProviderFactory.php
2 years ago
ProviderFactoryInterface.php
2 years ago
ProviderInterface.php
2 years ago
TranslationProviderCollection.php
2 years ago
TranslationProviderCollectionFactory.php
1 month ago
AbstractProviderFactory.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 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 IAWPSCOPED\Symfony\Component\Translation\Provider; |
| 12 | |
| 13 | use IAWPSCOPED\Symfony\Component\Translation\Exception\IncompleteDsnException; |
| 14 | /** @internal */ |
| 15 | abstract class AbstractProviderFactory implements ProviderFactoryInterface |
| 16 | { |
| 17 | public function supports(Dsn $dsn) : bool |
| 18 | { |
| 19 | return \in_array($dsn->getScheme(), $this->getSupportedSchemes(), \true); |
| 20 | } |
| 21 | /** |
| 22 | * @return string[] |
| 23 | */ |
| 24 | protected abstract function getSupportedSchemes() : array; |
| 25 | protected function getUser(Dsn $dsn) : string |
| 26 | { |
| 27 | if (null === ($user = $dsn->getUser())) { |
| 28 | throw new IncompleteDsnException('User is not set.', $dsn->getOriginalDsn()); |
| 29 | } |
| 30 | return $user; |
| 31 | } |
| 32 | protected function getPassword(Dsn $dsn) : string |
| 33 | { |
| 34 | if (null === ($password = $dsn->getPassword())) { |
| 35 | throw new IncompleteDsnException('Password is not set.', $dsn->getOriginalDsn()); |
| 36 | } |
| 37 | return $password; |
| 38 | } |
| 39 | } |
| 40 |