public function when()
{
$arguments = func_get_args();
if ($arguments[0] instanceof Antecedent) {
$antecedent = $arguments[0];
} elseif ($arguments[0] instanceof PHPUnit_Framework_Constraint) {
$antecedent = Antecedent\IndependentConstraintsAntecedent::fromAll($arguments);
} elseif ($arguments && count($arguments) == 1) {
$antecedent = Antecedent\SingleCallbackAntecedent::from($arguments[0]);
} else {
throw new \InvalidArgumentException("Invalid call to when(): " . var_export($arguments, true));
}
$this->antecedents[] = $antecedent;
return $this;
}