1: <?php
2: /**
3: * PHP Token Reflection
4: *
5: * Version 1.3.1
6: *
7: * LICENSE
8: *
9: * This source file is subject to the new BSD license that is bundled
10: * with this library in the file LICENSE.
11: *
12: * @author Ondřej Nešpor
13: * @author Jaroslav Hanslík
14: */
15:
16: namespace TokenReflection\Exception;
17:
18: use TokenReflection\IReflection;
19:
20: /**
21: * Runtime exception raised when working with a reflection element.
22: */
23: class RuntimeException extends BaseException
24: {
25: /**
26: * The property/method is not accessible.
27: *
28: * @var integer
29: */
30: const NOT_ACCESSBILE = 3002;
31:
32: /**
33: * The reflection element that caused this exception to be raised.
34: *
35: * @var \TokenReflection\IReflection
36: */
37: private $sender;
38:
39: /**
40: * Constructor.
41: *
42: * @param string $message Exception message
43: * @param integer $code Exception code
44: * @param \TokenReflection\IReflection $sender Reflection element
45: */
46: public function __construct($message, $code, IReflection $sender = null)
47: {
48: parent::__construct($message, $code);
49:
50: $this->sender = $sender;
51: }
52:
53: /**
54: * Returns the reflection element that caused the exception to be raised.
55: *
56: * @return \TokenReflection\IReflection
57: */
58: public function getSender()
59: {
60: return $this->sender;
61: }
62:
63: /**
64: * Returns an exception description detail.
65: *
66: * @return string
67: */
68: public function getDetail()
69: {
70: return null === $this->sender ? '' : sprintf('Thrown when working with "%s".', $this->sender->getPrettyName());
71: }
72: }
73: