1 | <?php |
||
23 | final class Leo |
||
24 | { |
||
25 | /** |
||
26 | * @var \Peridot\Leo\Leo |
||
27 | */ |
||
28 | private static $instance; |
||
29 | |||
30 | /** |
||
31 | * @var FormatterInterface |
||
32 | */ |
||
33 | protected $formatter; |
||
34 | |||
35 | /** |
||
36 | * @var ResponderInterface |
||
37 | */ |
||
38 | protected $responder; |
||
39 | |||
40 | /** |
||
41 | * @var Assertion |
||
42 | */ |
||
43 | protected $assertion; |
||
44 | |||
45 | /** |
||
46 | * Private access Constructor. |
||
47 | */ |
||
48 | private function __construct() |
||
56 | |||
57 | /** |
||
58 | * Return the Leo Assertion. |
||
59 | * |
||
60 | * @return Assertion |
||
61 | */ |
||
62 | public function getAssertion() |
||
66 | |||
67 | /** |
||
68 | * Set the Assertion used by Leo. |
||
69 | * |
||
70 | * @param $assertion |
||
71 | * @return $this |
||
72 | */ |
||
73 | public function setAssertion($assertion) |
||
79 | |||
80 | /** |
||
81 | * Return the FormatterInterface used by Leo. |
||
82 | * |
||
83 | * @return FormatterInterface |
||
84 | */ |
||
85 | public function getFormatter() |
||
89 | |||
90 | /** |
||
91 | * Set the FormatterInterface used by Leo. |
||
92 | * |
||
93 | * @param FormatterInterface $formatter |
||
94 | * @return $this |
||
95 | */ |
||
96 | public function setFormatter(FormatterInterface $formatter) |
||
102 | |||
103 | /** |
||
104 | * Return the ResponderInterface being used by Leo. |
||
105 | * |
||
106 | * @return ResponderInterface |
||
107 | */ |
||
108 | public function getResponder() |
||
112 | |||
113 | /** |
||
114 | * Set the ResponderInterface used by Leo. |
||
115 | * |
||
116 | * @param ResponderInterface $responder |
||
117 | * @return $this |
||
118 | */ |
||
119 | public function setResponder(ResponderInterface $responder) |
||
125 | |||
126 | /** |
||
127 | * Singleton access to Leo. A singleton is used instead of a facade as |
||
128 | * PHP has some hangups about binding scope from static methods. This should |
||
129 | * be used to access all Assertion members. |
||
130 | * |
||
131 | * @code |
||
132 | * |
||
133 | * $assertion = Leo::instance()->getAssertion(); |
||
134 | * $assertion->extend(function($assertion)) { |
||
135 | * $assertion->addMethod('coolAssertion', function($expected, $message = "") { |
||
136 | * $this->flag('message', $message); |
||
137 | * return new CoolMatcher($expected); |
||
138 | * }); |
||
139 | * }); |
||
140 | * |
||
141 | * @endcode |
||
142 | * |
||
143 | * @return Leo |
||
144 | */ |
||
145 | public static function instance() |
||
153 | |||
154 | /** |
||
155 | * Singleton access to Leo's assertion object. |
||
156 | * |
||
157 | * @return Assertion |
||
158 | */ |
||
159 | public static function assertion() |
||
163 | } |
||
164 |