@@ -31,6 +31,13 @@ class Experiment
3131 */
3232 protected $ control ;
3333
34+ /**
35+ * Context for the control.
36+ *
37+ * @var mixed
38+ */
39+ protected $ controlContext ;
40+
3441 /**
3542 * Trial callbacks.
3643 *
@@ -104,12 +111,14 @@ public function getLaboratory()
104111 * Register a control callback.
105112 *
106113 * @param callable $callback
114+ * @param mixed $context
107115 *
108116 * @return $this
109117 */
110- public function control (callable $ callback )
118+ public function control (callable $ callback, $ context = null )
111119 {
112120 $ this ->control = $ callback ;
121+ $ this ->controlContext = $ context ;
113122
114123 return $ this ;
115124 }
@@ -124,6 +133,11 @@ public function getControl()
124133 return $ this ->control ;
125134 }
126135
136+ public function getControlContext ()
137+ {
138+ return $ this ->controlContext ;
139+ }
140+
127141 /**
128142 * Register a trial callback.
129143 *
@@ -132,9 +146,9 @@ public function getControl()
132146 *
133147 * @return $this
134148 */
135- public function trial ($ name , callable $ callback )
149+ public function trial ($ name , callable $ callback, $ context = null )
136150 {
137- $ this ->trials [$ name ] = $ callback ;
151+ $ this ->trials [$ name ] = new Trial ( $ name , $ callback, $ context ) ;
138152
139153 return $ this ;
140154 }
@@ -148,7 +162,7 @@ public function trial($name, callable $callback)
148162 */
149163 public function getTrial ($ name )
150164 {
151- return $ this ->trials [$ name ];
165+ return $ this ->trials [$ name ]-> getCallback () ;
152166 }
153167
154168 /**
0 commit comments