| 1: | <?php declare(strict_types=1); |
| 2: | |
| 3: | namespace Salient\Core\Exception; |
| 4: | |
| 5: | use Salient\Contract\Core\Exception\MethodNotImplementedException as 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: | |
| 26: | |
| 27: | public function __construct(string $class, string $method, ?string $prototypeClass = null) |
| 28: | { |
| 29: | $prototypeClass ??= |
| 30: | Reflect::getPrototypeClass( |
| 31: | new ReflectionMethod($class, $method) |
| 32: | )->name; |
| 33: | |
| 34: | $this->Class = $class; |
| 35: | $this->Method = $method; |
| 36: | $this->PrototypeClass = $prototypeClass; |
| 37: | |
| 38: | parent::__construct(sprintf( |
| 39: | '%s does not implement %s::%s()', |
| 40: | $class, |
| 41: | $prototypeClass, |
| 42: | $method, |
| 43: | )); |
| 44: | } |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | public function getClass(): string |
| 50: | { |
| 51: | return $this->Class; |
| 52: | } |
| 53: | |
| 54: | |
| 55: | |
| 56: | |
| 57: | public function getMethod(): string |
| 58: | { |
| 59: | return $this->Method; |
| 60: | } |
| 61: | |
| 62: | |
| 63: | |
| 64: | |
| 65: | public function getPrototypeClass(): string |
| 66: | { |
| 67: | return $this->PrototypeClass; |
| 68: | } |
| 69: | } |
| 70: | |