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: * @api
12: */
13: class MethodNotImplementedException extends LogicException implements MethodNotImplementedExceptionInterface
14: {
15: /** @var class-string */
16: protected string $Class;
17: protected string $Method;
18: /** @var class-string */
19: protected string $PrototypeClass;
20:
21: /**
22: * @param class-string $class
23: * @param class-string|null $prototypeClass
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: * @inheritDoc
45: */
46: public function getClass(): string
47: {
48: return $this->Class;
49: }
50:
51: /**
52: * @inheritDoc
53: */
54: public function getMethod(): string
55: {
56: return $this->Method;
57: }
58:
59: /**
60: * @inheritDoc
61: */
62: public function getPrototypeClass(): string
63: {
64: return $this->PrototypeClass;
65: }
66: }
67: