public function get($subject, $workflowName = null)
{
$matched = null;
foreach ($this->workflows as list($workflow, $className)) {
if ($this->supports($workflow, $className, $subject, $workflowName)) {
if ($matched) {
throw new InvalidArgumentException('At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.');
}
$matched = $workflow;
}
}
if (!$matched) {
throw new InvalidArgumentException(sprintf('Unable to find a workflow for class "%s".', get_class($subject)));
}
return $matched;
}