mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-12 19:06:24 +02:00
some comments and refactoring for D.R.Y
This commit is contained in:
@ -29,8 +29,9 @@ abstract class Role
|
|||||||
preg_match('#([^\\\\]+)$#', $fqcn, $extract);
|
preg_match('#([^\\\\]+)$#', $fqcn, $extract);
|
||||||
$visitingMethod = 'visit' . $extract[1];
|
$visitingMethod = 'visit' . $extract[1];
|
||||||
|
|
||||||
if (!method_exists('DesignPatterns\Visitor\RoleVisitor', $visitingMethod)) {
|
// this ensures strong typing with visitor interface, not some visitor objects
|
||||||
throw new \InvalidArgumentException("The visitor you provide cannot visit a $fqcn object");
|
if (!method_exists(__NAMESPACE__ . '\RoleVisitor', $visitingMethod)) {
|
||||||
|
throw new \InvalidArgumentException("The visitor you provide cannot visit a $fqcn instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
call_user_func(array($visitor, $visitingMethod), $this);
|
call_user_func(array($visitor, $visitingMethod), $this);
|
||||||
|
Reference in New Issue
Block a user