1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Core\Exception; |
4: | |
5: | use Salient\Contract\Core\Exception\MethodNotImplementedExceptionInterface; |
6: | use Salient\Utility\Reflect; |
7: | use LogicException; |
8: | use ReflectionMethod; |
9: | |
10: | |
11: | |
12: | |
13: | class MethodNotImplementedException extends LogicException implements MethodNotImplementedExceptionInterface |
14: | { |
15: | |
16: | protected string $Class; |
17: | protected string $Method; |
18: | |
19: | protected string $PrototypeClass; |
20: | |
21: | |
22: | |
23: | |
24: | |
25: | public function __construct(string $class, string $method, ?string $prototypeClass = null) |
26: | { |
27: | $prototypeClass ??= Reflect::getPrototypeClass( |
28: | new ReflectionMethod($class, $method) |
29: | )->getName(); |
30: | |
31: | $this->Class = $class; |
32: | $this->Method = $method; |
33: | $this->PrototypeClass = $prototypeClass; |
34: | |
35: | parent::__construct(sprintf( |
36: | '%s does not implement %s::%s()', |
37: | $class, |
38: | $prototypeClass, |
39: | $method, |
40: | )); |
41: | } |
42: | |
43: | |
44: | |
45: | |
46: | public function getClass(): string |
47: | { |
48: | return $this->Class; |
49: | } |
50: | |
51: | |
52: | |
53: | |
54: | public function getMethod(): string |
55: | { |
56: | return $this->Method; |
57: | } |
58: | |
59: | |
60: | |
61: | |
62: | public function getPrototypeClass(): string |
63: | { |
64: | return $this->PrototypeClass; |
65: | } |
66: | } |
67: | |