mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-13 02:14:04 +02:00
Applied fixes from StyleCI
This commit is contained in:
committed by
StyleCI Bot
parent
3663603b80
commit
fe1f144ec3
@@ -3,12 +3,12 @@
|
||||
namespace DesignPatterns\Behavioral\Visitor;
|
||||
|
||||
/**
|
||||
* class Role
|
||||
* class Role.
|
||||
*/
|
||||
abstract class Role
|
||||
{
|
||||
/**
|
||||
* This method handles a double dispatch based on the short name of the Visitor
|
||||
* This method handles a double dispatch based on the short name of the Visitor.
|
||||
*
|
||||
* Feel free to override it if your object must call another visiting behavior
|
||||
*
|
||||
@@ -21,10 +21,10 @@ abstract class Role
|
||||
// this trick to simulate double-dispatch based on type-hinting
|
||||
$klass = get_called_class();
|
||||
preg_match('#([^\\\\]+)$#', $klass, $extract);
|
||||
$visitingMethod = 'visit' . $extract[1];
|
||||
$visitingMethod = 'visit'.$extract[1];
|
||||
|
||||
// this ensures strong typing with visitor interface, not some visitor objects
|
||||
if (!method_exists(__NAMESPACE__ . '\RoleVisitorInterface', $visitingMethod)) {
|
||||
if (!method_exists(__NAMESPACE__.'\RoleVisitorInterface', $visitingMethod)) {
|
||||
throw new \InvalidArgumentException("The visitor you provide cannot visit a $klass instance");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user