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: | |
15: | |
16: | |
17: | private $identifier; |
18: | public function __construct(string $message, Identifier $identifier) |
19: | { |
20: | $this->identifier = $identifier; |
21: | parent::__construct($message); |
22: | } |
23: | |
24: | public function getIdentifier(): Identifier |
25: | { |
26: | return $this->identifier; |
27: | } |
28: | |
29: | public static function fromIdentifier(Identifier $identifier): self |
30: | { |
31: | return new self(sprintf('%s "%s" could not be found in the located source', $identifier->getType()->getName(), $identifier->getName()), $identifier); |
32: | } |
33: | } |
34: | |