1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace PHPStan\BetterReflection\Reflector\Exception;
6:
7: use PHPStan\BetterReflection\Identifier\Identifier;
8: use RuntimeException;
9:
10: use function sprintf;
11:
12: class IdentifierNotFound extends RuntimeException
13: {
14: private Identifier $identifier;
15: public function __construct(string $message, Identifier $identifier)
16: {
17: $this->identifier = $identifier;
18: parent::__construct($message);
19: }
20:
21: public function getIdentifier(): Identifier
22: {
23: return $this->identifier;
24: }
25:
26: public static function fromIdentifier(Identifier $identifier): self
27: {
28: return new self(sprintf(
29: '%s "%s" could not be found in the located source',
30: $identifier->getType()->getName(),
31: $identifier->getName(),
32: ), $identifier);
33: }
34: }
35: