remove Interface-Suffix

This commit is contained in:
Dominik Liebler 2019-08-19 17:07:39 +02:00
parent 27bd89dd63
commit 9cb7660704
No known key found for this signature in database
GPG Key ID: DCE4AADEA26FD47B
9 changed files with 49 additions and 49 deletions

View File

@ -20,7 +20,7 @@ class Group implements Role
return sprintf('Group: %s', $this->name);
}
public function accept(RoleVisitorInterface $visitor)
public function accept(RoleVisitor $visitor)
{
$visitor->visitGroup($this);
}

View File

@ -25,18 +25,18 @@ Code
You can also find this code on `GitHub`_
RoleVisitorInterface.php
.. literalinclude:: RoleVisitorInterface.php
:language: php
:linenos:
RoleVisitor.php
.. literalinclude:: RoleVisitor.php
:language: php
:linenos:
RecordingVisitor.php
.. literalinclude:: RecordingVisitor.php
:language: php
:linenos:
Role.php
.. literalinclude:: Role.php
@ -65,4 +65,4 @@ Tests/VisitorTest.php
:linenos:
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/Behavioral/Visitor
.. __: http://en.wikipedia.org/wiki/Visitor_pattern
.. __: http://en.wikipedia.org/wiki/Visitor_pattern

View File

@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace DesignPatterns\Behavioral\Visitor;
class RecordingVisitor implements RoleVisitor
{
/**
* @var Role[]
*/
private $visited = [];
public function visitGroup(Group $role)
{
$this->visited[] = $role;
}
public function visitUser(User $role)
{
$this->visited[] = $role;
}
/**
* @return Role[]
*/
public function getVisited(): array
{
return $this->visited;
}
}

View File

@ -5,5 +5,5 @@ namespace DesignPatterns\Behavioral\Visitor;
interface Role
{
public function accept(RoleVisitorInterface $visitor);
public function accept(RoleVisitor $visitor);
}

View File

@ -3,28 +3,13 @@ declare(strict_types=1);
namespace DesignPatterns\Behavioral\Visitor;
class RoleVisitor implements RoleVisitorInterface
/**
* Note: the visitor must not choose itself which method to
* invoke, it is the Visitee that make this decision
*/
interface RoleVisitor
{
/**
* @var Role[]
*/
private $visited = [];
public function visitUser(User $role);
public function visitGroup(Group $role)
{
$this->visited[] = $role;
}
public function visitUser(User $role)
{
$this->visited[] = $role;
}
/**
* @return Role[]
*/
public function getVisited(): array
{
return $this->visited;
}
public function visitGroup(Group $role);
}

View File

@ -1,15 +0,0 @@
<?php
declare(strict_types=1);
namespace DesignPatterns\Behavioral\Visitor;
/**
* Note: the visitor must not choose itself which method to
* invoke, it is the Visitee that make this decision
*/
interface RoleVisitorInterface
{
public function visitUser(User $role);
public function visitGroup(Group $role);
}

View File

@ -9,13 +9,13 @@ use PHPUnit\Framework\TestCase;
class VisitorTest extends TestCase
{
/**
* @var Visitor\RoleVisitor
* @var Visitor\RecordingVisitor
*/
private $visitor;
protected function setUp(): void
{
$this->visitor = new Visitor\RoleVisitor();
$this->visitor = new Visitor\RecordingVisitor();
}
public function provideRoles()

View File

@ -20,7 +20,7 @@ class User implements Role
return sprintf('User %s', $this->name);
}
public function accept(RoleVisitorInterface $visitor)
public function accept(RoleVisitor $visitor)
{
$visitor->visitUser($this);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 57 KiB