wordpress-seo
/
vendor_prefixed
/
symfony
/
dependency-injection
/
Exception
/
ServiceNotFoundException.php
ServiceNotFoundException.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at vendor_prefixed/symfony/dependency-injection/Exception/ServiceNotFoundException.php
| 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 YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception; |
| 12 | |
| 13 | use YoastSEO_Vendor\Psr\Container\NotFoundExceptionInterface; |
| 14 | /** |
| 15 | * This exception is thrown when a non-existent service is requested. |
| 16 | * |
| 17 | * @author Johannes M. Schmitt <schmittjoh@gmail.com> |
| 18 | */ |
| 19 | class ServiceNotFoundException extends \YoastSEO_Vendor\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException implements \YoastSEO_Vendor\Psr\Container\NotFoundExceptionInterface |
| 20 | { |
| 21 | private $id; |
| 22 | private $sourceId; |
| 23 | private $alternatives; |
| 24 | public function __construct(string $id, ?string $sourceId = null, ?\Throwable $previous = null, array $alternatives = [], ?string $msg = null) |
| 25 | { |
| 26 | if (null !== $msg) { |
| 27 | // no-op |
| 28 | } elseif (null === $sourceId) { |
| 29 | $msg = \sprintf('You have requested a non-existent service "%s".', $id); |
| 30 | } else { |
| 31 | $msg = \sprintf('The service "%s" has a dependency on a non-existent service "%s".', $sourceId, $id); |
| 32 | } |
| 33 | if ($alternatives) { |
| 34 | if (1 == \count($alternatives)) { |
| 35 | $msg .= ' Did you mean this: "'; |
| 36 | } else { |
| 37 | $msg .= ' Did you mean one of these: "'; |
| 38 | } |
| 39 | $msg .= \implode('", "', $alternatives) . '"?'; |
| 40 | } |
| 41 | parent::__construct($msg, 0, $previous); |
| 42 | $this->id = $id; |
| 43 | $this->sourceId = $sourceId; |
| 44 | $this->alternatives = $alternatives; |
| 45 | } |
| 46 | public function getId() |
| 47 | { |
| 48 | return $this->id; |
| 49 | } |
| 50 | public function getSourceId() |
| 51 | { |
| 52 | return $this->sourceId; |
| 53 | } |
| 54 | public function getAlternatives() |
| 55 | { |
| 56 | return $this->alternatives; |
| 57 | } |
| 58 | } |
| 59 |