From fe1f144ec3ce1d09452e67bce12e3a58f0f8657e Mon Sep 17 00:00:00 2001 From: Dominik Liebler Date: Mon, 21 Dec 2015 07:28:20 -0500 Subject: [PATCH] Applied fixes from StyleCI --- .../ChainOfResponsibilities/Handler.php | 6 +- .../Responsible/FastStorage.php | 2 +- .../Responsible/SlowStorage.php | 3 +- .../Tests/ChainTest.php | 7 +- Behavioral/Command/CommandInterface.php | 2 +- Behavioral/Command/HelloCommand.php | 4 +- Behavioral/Command/Invoker.php | 4 +- Behavioral/Command/Receiver.php | 2 +- Behavioral/Command/Tests/CommandTest.php | 5 +- Behavioral/Iterator/Book.php | 3 +- Behavioral/Iterator/BookList.php | 3 +- Behavioral/Iterator/BookListIterator.php | 25 +++++-- .../Iterator/BookListReverseIterator.php | 25 +++++-- Behavioral/Iterator/Tests/IteratorTest.php | 7 +- Behavioral/Mediator/Colleague.php | 5 +- Behavioral/Mediator/Mediator.php | 10 +-- Behavioral/Mediator/MediatorInterface.php | 8 +- Behavioral/Mediator/Subsystem/Client.php | 6 +- Behavioral/Mediator/Subsystem/Database.php | 4 +- Behavioral/Mediator/Subsystem/Server.php | 4 +- Behavioral/Mediator/Tests/MediatorTest.php | 5 +- Behavioral/Memento/Caretaker.php | 8 +- Behavioral/Memento/Tests/MementoTest.php | 74 +++++++++---------- Behavioral/NullObject/LoggerInterface.php | 2 +- Behavioral/NullObject/PrintLogger.php | 2 +- Behavioral/NullObject/Service.php | 6 +- Behavioral/NullObject/Tests/LoggerTest.php | 5 +- Behavioral/Observer/Tests/ObserverTest.php | 11 ++- Behavioral/Observer/User.php | 17 ++--- Behavioral/Observer/UserObserver.php | 6 +- .../Specification/AbstractSpecification.php | 11 +-- Behavioral/Specification/Either.php | 8 +- Behavioral/Specification/Item.php | 7 +- Behavioral/Specification/Not.php | 8 +- Behavioral/Specification/Plus.php | 8 +- .../Specification/PriceSpecification.php | 9 ++- .../Specification/SpecificationInterface.php | 11 +-- .../Specification/Tests/SpecificationTest.php | 4 +- Behavioral/State/CreateOrder.php | 5 +- Behavioral/State/OrderController.php | 2 +- Behavioral/State/OrderFactory.php | 5 +- Behavioral/State/OrderInterface.php | 2 +- Behavioral/State/ShippingOrder.php | 5 +- Behavioral/Strategy/ComparatorInterface.php | 2 +- Behavioral/Strategy/DateComparator.php | 2 +- Behavioral/Strategy/IdComparator.php | 2 +- Behavioral/Strategy/ObjectCollection.php | 4 +- Behavioral/Strategy/Tests/StrategyTest.php | 11 ++- Behavioral/TemplateMethod/BeachJourney.php | 4 +- Behavioral/TemplateMethod/CityJourney.php | 4 +- Behavioral/TemplateMethod/Journey.php | 6 +- .../TemplateMethod/Tests/JourneyTest.php | 5 +- Behavioral/Visitor/Group.php | 4 +- Behavioral/Visitor/Role.php | 8 +- Behavioral/Visitor/RolePrintVisitor.php | 6 +- Behavioral/Visitor/RoleVisitorInterface.php | 6 +- Behavioral/Visitor/Tests/VisitorTest.php | 7 +- Behavioral/Visitor/User.php | 4 +- .../AbstractFactory/AbstractFactory.php | 6 +- Creational/AbstractFactory/Html/Picture.php | 4 +- Creational/AbstractFactory/Html/Text.php | 6 +- Creational/AbstractFactory/HtmlFactory.php | 6 +- Creational/AbstractFactory/Json/Picture.php | 4 +- Creational/AbstractFactory/Json/Text.php | 4 +- Creational/AbstractFactory/JsonFactory.php | 7 +- Creational/AbstractFactory/MediaInterface.php | 5 +- Creational/AbstractFactory/Picture.php | 3 +- .../Tests/AbstractFactoryTest.php | 6 +- Creational/AbstractFactory/Text.php | 2 +- Creational/Builder/BikeBuilder.php | 2 +- Creational/Builder/CarBuilder.php | 2 +- Creational/Builder/Director.php | 3 +- Creational/Builder/Parts/Bike.php | 2 +- Creational/Builder/Parts/Car.php | 2 +- Creational/Builder/Parts/Door.php | 2 +- Creational/Builder/Parts/Engine.php | 2 +- Creational/Builder/Parts/Vehicle.php | 2 +- Creational/Builder/Parts/Wheel.php | 2 +- Creational/Builder/Tests/DirectorTest.php | 9 +-- Creational/FactoryMethod/Bicycle.php | 4 +- Creational/FactoryMethod/FactoryMethod.php | 9 +-- Creational/FactoryMethod/Ferrari.php | 2 +- Creational/FactoryMethod/GermanFactory.php | 2 +- Creational/FactoryMethod/ItalianFactory.php | 2 +- Creational/FactoryMethod/Porsche.php | 2 +- .../FactoryMethod/Tests/FactoryMethodTest.php | 7 +- Creational/FactoryMethod/VehicleInterface.php | 4 +- Creational/Multiton/Multiton.php | 17 ++--- Creational/Pool/Pool.php | 1 - Creational/Pool/Processor.php | 3 +- Creational/Pool/Worker.php | 1 - Creational/Prototype/BarBookPrototype.php | 4 +- Creational/Prototype/BookPrototype.php | 3 +- Creational/Prototype/FooBookPrototype.php | 4 +- Creational/Prototype/index.php | 4 +- Creational/SimpleFactory/Bicycle.php | 2 +- Creational/SimpleFactory/ConcreteFactory.php | 11 +-- Creational/SimpleFactory/Scooter.php | 2 +- .../SimpleFactory/Tests/SimpleFactoryTest.php | 5 +- Creational/SimpleFactory/VehicleInterface.php | 2 +- Creational/Singleton/Singleton.php | 23 +++--- .../SingletonPatternViolationException.php | 1 - Creational/Singleton/Tests/SingletonTest.php | 5 +- Creational/StaticFactory/FormatNumber.php | 2 +- Creational/StaticFactory/FormatString.php | 2 +- .../StaticFactory/FormatterInterface.php | 2 +- Creational/StaticFactory/StaticFactory.php | 7 +- .../StaticFactory/Tests/StaticFactoryTest.php | 8 +- More/Delegation/JuniorDeveloper.php | 5 +- More/Delegation/TeamLead.php | 10 +-- More/Delegation/Tests/DelegationTest.php | 2 +- More/EAV/Attribute.php | 5 +- More/EAV/Entity.php | 5 +- More/EAV/Tests/AttributeTest.php | 2 +- More/EAV/Tests/EntityTest.php | 10 +-- More/EAV/Tests/ValueTest.php | 2 +- More/EAV/Value.php | 4 +- More/EAV/ValueAccessInterface.php | 2 +- More/EAV/ValueInterface.php | 2 +- More/EAV/example.php | 31 ++++---- More/Repository/MemoryStorage.php | 7 +- More/Repository/Post.php | 3 +- More/Repository/PostRepository.php | 19 ++--- More/Repository/Storage.php | 13 ++-- More/ServiceLocator/ServiceLocator.php | 15 ++-- .../Tests/ServiceLocatorTest.php | 6 +- Structural/Adapter/Book.php | 2 +- Structural/Adapter/EBookAdapter.php | 8 +- Structural/Adapter/EBookInterface.php | 6 +- Structural/Adapter/Kindle.php | 2 +- Structural/Adapter/PaperBookInterface.php | 6 +- Structural/Adapter/Tests/AdapterTest.php | 8 +- Structural/Bridge/Assemble.php | 3 +- Structural/Bridge/Car.php | 5 +- Structural/Bridge/Motorcycle.php | 5 +- Structural/Bridge/Produce.php | 5 +- Structural/Bridge/Tests/BridgeTest.php | 1 - Structural/Bridge/Vehicle.php | 3 +- Structural/Bridge/Workshop.php | 3 +- Structural/Composite/Form.php | 4 +- Structural/Composite/FormElement.php | 4 +- Structural/Composite/InputElement.php | 6 +- Structural/Composite/Tests/CompositeTest.php | 5 +- Structural/Composite/TextElement.php | 6 +- .../DataMapper/Tests/DataMapperTest.php | 8 +- Structural/DataMapper/User.php | 3 +- Structural/DataMapper/UserMapper.php | 19 ++--- Structural/Decorator/Decorator.php | 2 +- Structural/Decorator/RenderInJson.php | 4 +- Structural/Decorator/RenderInXml.php | 4 +- Structural/Decorator/RendererInterface.php | 4 +- Structural/Decorator/Tests/DecoratorTest.php | 11 ++- Structural/Decorator/Webservice.php | 2 +- .../DependencyInjection/AbstractConfig.php | 2 +- .../DependencyInjection/ArrayConfig.php | 12 +-- Structural/DependencyInjection/Connection.php | 5 +- Structural/DependencyInjection/Parameters.php | 6 +- Structural/Facade/BiosInterface.php | 10 +-- Structural/Facade/Facade.php | 7 +- Structural/Facade/OsInterface.php | 4 +- Structural/Facade/Tests/FacadeTest.php | 4 +- Structural/FluentInterface/Sql.php | 18 ++--- .../Tests/FluentInterfaceTest.php | 3 +- Structural/Proxy/Record.php | 8 +- Structural/Proxy/RecordProxy.php | 4 +- Structural/Registry/Registry.php | 8 +- Structural/Registry/Tests/RegistryTest.php | 1 - 167 files changed, 510 insertions(+), 517 deletions(-) diff --git a/Behavioral/ChainOfResponsibilities/Handler.php b/Behavioral/ChainOfResponsibilities/Handler.php index f080e2351..679734e45 100644 --- a/Behavioral/ChainOfResponsibilities/Handler.php +++ b/Behavioral/ChainOfResponsibilities/Handler.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\ChainOfResponsibilities; /** - * Handler is a generic handler in the chain of responsibilities + * Handler is a generic handler in the chain of responsibilities. * * Yes you could have a lighter CoR with a simpler handler but if you want your CoR * to be extendable and decoupled, it's a better idea to do things like that in real @@ -18,7 +18,7 @@ abstract class Handler private $successor = null; /** - * Append a responsibility to the end of chain + * Append a responsibility to the end of chain. * * A prepend method could be done with the same spirit * @@ -68,7 +68,7 @@ final public function handle(Request $req) } /** - * Each concrete handler has to implement the processing of the request + * Each concrete handler has to implement the processing of the request. * * @param Request $req * diff --git a/Behavioral/ChainOfResponsibilities/Responsible/FastStorage.php b/Behavioral/ChainOfResponsibilities/Responsible/FastStorage.php index 4a7464275..8acaad185 100644 --- a/Behavioral/ChainOfResponsibilities/Responsible/FastStorage.php +++ b/Behavioral/ChainOfResponsibilities/Responsible/FastStorage.php @@ -6,7 +6,7 @@ use DesignPatterns\Behavioral\ChainOfResponsibilities\Request; /** - * Class FastStorage + * Class FastStorage. */ class FastStorage extends Handler { diff --git a/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php b/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php index 127b7fca9..bd3f825f3 100644 --- a/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php +++ b/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php @@ -6,14 +6,13 @@ use DesignPatterns\Behavioral\ChainOfResponsibilities\Request; /** - * This is mostly the same code as FastStorage but in fact, it may greatly differs + * This is mostly the same code as FastStorage but in fact, it may greatly differs. * * One important fact about CoR: each item in the chain MUST NOT assume its position * in the chain. A CoR is not responsible if the request is not handled UNLESS * you make an "ExceptionHandler" which throws exception if the request goes there. * * To be really extendable, each handler doesn't know if there is something after it. - * */ class SlowStorage extends Handler { diff --git a/Behavioral/ChainOfResponsibilities/Tests/ChainTest.php b/Behavioral/ChainOfResponsibilities/Tests/ChainTest.php index 0e8357ce4..62d117226 100644 --- a/Behavioral/ChainOfResponsibilities/Tests/ChainTest.php +++ b/Behavioral/ChainOfResponsibilities/Tests/ChainTest.php @@ -3,16 +3,15 @@ namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Tests; use DesignPatterns\Behavioral\ChainOfResponsibilities\Request; +use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible; use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage; use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage; -use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible; /** - * ChainTest tests the CoR + * ChainTest tests the CoR. */ class ChainTest extends \PHPUnit_Framework_TestCase { - /** * @var FastStorage */ @@ -30,7 +29,7 @@ public function makeRequest() $request->verb = 'get'; return array( - array($request) + array($request), ); } diff --git a/Behavioral/Command/CommandInterface.php b/Behavioral/Command/CommandInterface.php index ad9117b92..cd9d9c631 100644 --- a/Behavioral/Command/CommandInterface.php +++ b/Behavioral/Command/CommandInterface.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\Command; /** - * class CommandInterface + * class CommandInterface. */ interface CommandInterface { diff --git a/Behavioral/Command/HelloCommand.php b/Behavioral/Command/HelloCommand.php index 831c299ca..94d47236e 100644 --- a/Behavioral/Command/HelloCommand.php +++ b/Behavioral/Command/HelloCommand.php @@ -4,7 +4,7 @@ /** * This concrete command calls "print" on the Receiver, but an external - * invoker just knows that it can call "execute" + * invoker just knows that it can call "execute". */ class HelloCommand implements CommandInterface { @@ -25,7 +25,7 @@ public function __construct(Receiver $console) } /** - * execute and output "Hello World" + * execute and output "Hello World". */ public function execute() { diff --git a/Behavioral/Command/Invoker.php b/Behavioral/Command/Invoker.php index 4461ee279..7942adb32 100644 --- a/Behavioral/Command/Invoker.php +++ b/Behavioral/Command/Invoker.php @@ -4,7 +4,7 @@ /** * Invoker is using the command given to it. - * Example : an Application in SF2 + * Example : an Application in SF2. */ class Invoker { @@ -25,7 +25,7 @@ public function setCommand(CommandInterface $cmd) } /** - * executes the command + * executes the command. */ public function run() { diff --git a/Behavioral/Command/Receiver.php b/Behavioral/Command/Receiver.php index 9289369b2..ccf910b54 100644 --- a/Behavioral/Command/Receiver.php +++ b/Behavioral/Command/Receiver.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\Command; /** - * Receiver is specific service with its own contract and can be only concrete + * Receiver is specific service with its own contract and can be only concrete. */ class Receiver { diff --git a/Behavioral/Command/Tests/CommandTest.php b/Behavioral/Command/Tests/CommandTest.php index abf731763..9d9aa51b6 100644 --- a/Behavioral/Command/Tests/CommandTest.php +++ b/Behavioral/Command/Tests/CommandTest.php @@ -2,16 +2,15 @@ namespace DesignPatterns\Behavioral\Command\Tests; +use DesignPatterns\Behavioral\Command\HelloCommand; use DesignPatterns\Behavioral\Command\Invoker; use DesignPatterns\Behavioral\Command\Receiver; -use DesignPatterns\Behavioral\Command\HelloCommand; /** - * CommandTest has the role of the Client in the Command Pattern + * CommandTest has the role of the Client in the Command Pattern. */ class CommandTest extends \PHPUnit_Framework_TestCase { - /** * @var Invoker */ diff --git a/Behavioral/Iterator/Book.php b/Behavioral/Iterator/Book.php index a0d111483..b1adf7f85 100644 --- a/Behavioral/Iterator/Book.php +++ b/Behavioral/Iterator/Book.php @@ -4,7 +4,6 @@ class Book { - private $author; private $title; @@ -27,6 +26,6 @@ public function getTitle() public function getAuthorAndTitle() { - return $this->getTitle() . ' by ' . $this->getAuthor(); + return $this->getTitle().' by '.$this->getAuthor(); } } diff --git a/Behavioral/Iterator/BookList.php b/Behavioral/Iterator/BookList.php index 6773f9b51..6cc5e5ed6 100644 --- a/Behavioral/Iterator/BookList.php +++ b/Behavioral/Iterator/BookList.php @@ -4,7 +4,6 @@ class BookList implements \Countable { - private $books; public function getBook($bookNumberToGet) @@ -13,7 +12,7 @@ public function getBook($bookNumberToGet) return $this->books[$bookNumberToGet]; } - return null; + return; } public function addBook(Book $book) diff --git a/Behavioral/Iterator/BookListIterator.php b/Behavioral/Iterator/BookListIterator.php index 93df6d7f6..ecedba6e0 100644 --- a/Behavioral/Iterator/BookListIterator.php +++ b/Behavioral/Iterator/BookListIterator.php @@ -4,7 +4,6 @@ class BookListIterator implements \Iterator { - /** * @var BookList */ @@ -21,8 +20,10 @@ public function __construct(BookList $bookList) } /** - * Return the current book + * Return the current book. + * * @link http://php.net/manual/en/iterator.current.php + * * @return Book Can return any type. */ public function current() @@ -32,8 +33,10 @@ public function current() /** * (PHP 5 >= 5.0.0)
- * Move forward to next element + * Move forward to next element. + * * @link http://php.net/manual/en/iterator.next.php + * * @return void Any returned value is ignored. */ public function next() @@ -43,8 +46,10 @@ public function next() /** * (PHP 5 >= 5.0.0)
- * Return the key of the current element + * Return the key of the current element. + * * @link http://php.net/manual/en/iterator.key.php + * * @return mixed scalar on success, or null on failure. */ public function key() @@ -54,10 +59,12 @@ public function key() /** * (PHP 5 >= 5.0.0)
- * Checks if current position is valid + * Checks if current position is valid. + * * @link http://php.net/manual/en/iterator.valid.php - * @return boolean The return value will be casted to boolean and then evaluated. - * Returns true on success or false on failure. + * + * @return bool The return value will be casted to boolean and then evaluated. + * Returns true on success or false on failure. */ public function valid() { @@ -66,8 +73,10 @@ public function valid() /** * (PHP 5 >= 5.0.0)
- * Rewind the Iterator to the first element + * Rewind the Iterator to the first element. + * * @link http://php.net/manual/en/iterator.rewind.php + * * @return void Any returned value is ignored. */ public function rewind() diff --git a/Behavioral/Iterator/BookListReverseIterator.php b/Behavioral/Iterator/BookListReverseIterator.php index d7ec49a60..94f34d9b5 100644 --- a/Behavioral/Iterator/BookListReverseIterator.php +++ b/Behavioral/Iterator/BookListReverseIterator.php @@ -4,7 +4,6 @@ class BookListReverseIterator implements \Iterator { - /** * @var BookList */ @@ -22,8 +21,10 @@ public function __construct(BookList $bookList) } /** - * Return the current book + * Return the current book. + * * @link http://php.net/manual/en/iterator.current.php + * * @return Book Can return any type. */ public function current() @@ -33,8 +34,10 @@ public function current() /** * (PHP 5 >= 5.0.0)
- * Move forward to next element + * Move forward to next element. + * * @link http://php.net/manual/en/iterator.next.php + * * @return void Any returned value is ignored. */ public function next() @@ -44,8 +47,10 @@ public function next() /** * (PHP 5 >= 5.0.0)
- * Return the key of the current element + * Return the key of the current element. + * * @link http://php.net/manual/en/iterator.key.php + * * @return mixed scalar on success, or null on failure. */ public function key() @@ -55,10 +60,12 @@ public function key() /** * (PHP 5 >= 5.0.0)
- * Checks if current position is valid + * Checks if current position is valid. + * * @link http://php.net/manual/en/iterator.valid.php - * @return boolean The return value will be casted to boolean and then evaluated. - * Returns true on success or false on failure. + * + * @return bool The return value will be casted to boolean and then evaluated. + * Returns true on success or false on failure. */ public function valid() { @@ -67,8 +74,10 @@ public function valid() /** * (PHP 5 >= 5.0.0)
- * Rewind the Iterator to the first element + * Rewind the Iterator to the first element. + * * @link http://php.net/manual/en/iterator.rewind.php + * * @return void Any returned value is ignored. */ public function rewind() diff --git a/Behavioral/Iterator/Tests/IteratorTest.php b/Behavioral/Iterator/Tests/IteratorTest.php index 2c5acd97a..db386f06a 100644 --- a/Behavioral/Iterator/Tests/IteratorTest.php +++ b/Behavioral/Iterator/Tests/IteratorTest.php @@ -9,7 +9,6 @@ class IteratorTest extends \PHPUnit_Framework_TestCase { - /** * @var BookList */ @@ -30,8 +29,8 @@ public function expectedAuthors() array( 'Learning PHP Design Patterns by William Sanders', 'Professional Php Design Patterns by Aaron Saray', - 'Clean Code by Robert C. Martin' - ) + 'Clean Code by Robert C. Martin', + ), ), ); } @@ -65,7 +64,7 @@ public function testUseAReverseIteratorAndValidateAuthors($expected) } /** - * Test BookList Remove + * Test BookList Remove. */ public function testBookRemove() { diff --git a/Behavioral/Mediator/Colleague.php b/Behavioral/Mediator/Colleague.php index c0ff2486d..c74dee5ed 100644 --- a/Behavioral/Mediator/Colleague.php +++ b/Behavioral/Mediator/Colleague.php @@ -9,12 +9,12 @@ abstract class Colleague { /** - * this ensures no change in subclasses + * this ensures no change in subclasses. * * @var MediatorInterface */ private $mediator; - + /** * @param MediatorInterface $medium */ @@ -25,6 +25,7 @@ public function __construct(MediatorInterface $medium) } // for subclasses + protected function getMediator() { return $this->mediator; diff --git a/Behavioral/Mediator/Mediator.php b/Behavioral/Mediator/Mediator.php index ba1407ed5..98a789083 100644 --- a/Behavioral/Mediator/Mediator.php +++ b/Behavioral/Mediator/Mediator.php @@ -2,15 +2,12 @@ namespace DesignPatterns\Behavioral\Mediator; -use DesignPatterns\Behavioral\Mediator\Subsystem; - /** * Mediator is the concrete Mediator for this design pattern. * In this example, I have made a "Hello World" with the Mediator Pattern. */ class Mediator implements MediatorInterface { - /** * @var Subsystem\Server */ @@ -39,7 +36,7 @@ public function setColleague(Subsystem\Database $db, Subsystem\Client $cl, Subsy } /** - * make request + * make request. */ public function makeRequest() { @@ -47,7 +44,8 @@ public function makeRequest() } /** - * query db + * query db. + * * @return mixed */ public function queryDb() @@ -56,7 +54,7 @@ public function queryDb() } /** - * send response + * send response. * * @param string $content */ diff --git a/Behavioral/Mediator/MediatorInterface.php b/Behavioral/Mediator/MediatorInterface.php index b289cea5d..dbdd48920 100644 --- a/Behavioral/Mediator/MediatorInterface.php +++ b/Behavioral/Mediator/MediatorInterface.php @@ -4,24 +4,24 @@ /** * MediatorInterface is a contract for the Mediator - * This interface is not mandatory but it is better for LSP concerns + * This interface is not mandatory but it is better for LSP concerns. */ interface MediatorInterface { /** - * sends the response + * sends the response. * * @param string $content */ public function sendResponse($content); /** - * makes a request + * makes a request. */ public function makeRequest(); /** - * queries the DB + * queries the DB. */ public function queryDb(); } diff --git a/Behavioral/Mediator/Subsystem/Client.php b/Behavioral/Mediator/Subsystem/Client.php index cb4b0208e..f7a21c967 100644 --- a/Behavioral/Mediator/Subsystem/Client.php +++ b/Behavioral/Mediator/Subsystem/Client.php @@ -5,12 +5,12 @@ use DesignPatterns\Behavioral\Mediator\Colleague; /** - * Client is a client that make request et get response + * Client is a client that make request et get response. */ class Client extends Colleague { /** - * request + * request. */ public function request() { @@ -18,7 +18,7 @@ public function request() } /** - * output content + * output content. * * @param string $content */ diff --git a/Behavioral/Mediator/Subsystem/Database.php b/Behavioral/Mediator/Subsystem/Database.php index 7cc9bc4bb..69ad6cf6b 100644 --- a/Behavioral/Mediator/Subsystem/Database.php +++ b/Behavioral/Mediator/Subsystem/Database.php @@ -5,7 +5,7 @@ use DesignPatterns\Behavioral\Mediator\Colleague; /** - * Database is a database service + * Database is a database service. */ class Database extends Colleague { @@ -14,6 +14,6 @@ class Database extends Colleague */ public function getData() { - return "World"; + return 'World'; } } diff --git a/Behavioral/Mediator/Subsystem/Server.php b/Behavioral/Mediator/Subsystem/Server.php index 1638301a9..1602bcb3b 100644 --- a/Behavioral/Mediator/Subsystem/Server.php +++ b/Behavioral/Mediator/Subsystem/Server.php @@ -5,12 +5,12 @@ use DesignPatterns\Behavioral\Mediator\Colleague; /** - * Server serves responses + * Server serves responses. */ class Server extends Colleague { /** - * process on server + * process on server. */ public function process() { diff --git a/Behavioral/Mediator/Tests/MediatorTest.php b/Behavioral/Mediator/Tests/MediatorTest.php index 13abe484f..2bce947fe 100644 --- a/Behavioral/Mediator/Tests/MediatorTest.php +++ b/Behavioral/Mediator/Tests/MediatorTest.php @@ -3,16 +3,15 @@ namespace DesignPatterns\Tests\Mediator\Tests; use DesignPatterns\Behavioral\Mediator\Mediator; -use DesignPatterns\Behavioral\Mediator\Subsystem\Database; use DesignPatterns\Behavioral\Mediator\Subsystem\Client; +use DesignPatterns\Behavioral\Mediator\Subsystem\Database; use DesignPatterns\Behavioral\Mediator\Subsystem\Server; /** - * MediatorTest tests hello world + * MediatorTest tests hello world. */ class MediatorTest extends \PHPUnit_Framework_TestCase { - protected $client; protected function setUp() diff --git a/Behavioral/Memento/Caretaker.php b/Behavioral/Memento/Caretaker.php index 72530fb24..d80454a93 100644 --- a/Behavioral/Memento/Caretaker.php +++ b/Behavioral/Memento/Caretaker.php @@ -27,19 +27,19 @@ public function runCustomLogic() $originator = new Originator(); //Setting state to State1 - $originator->setState("State1"); + $originator->setState('State1'); //Setting state to State2 - $originator->setState("State2"); + $originator->setState('State2'); //Saving State2 to Memento $this->saveToHistory($originator->getStateAsMemento()); //Setting state to State3 - $originator->setState("State3"); + $originator->setState('State3'); // We can request multiple mementos, and choose which one to roll back to. // Saving State3 to Memento $this->saveToHistory($originator->getStateAsMemento()); //Setting state to State4 - $originator->setState("State4"); + $originator->setState('State4'); $originator->restoreFromMemento($this->getFromHistory(1)); //State after restoring from Memento: State3 diff --git a/Behavioral/Memento/Tests/MementoTest.php b/Behavioral/Memento/Tests/MementoTest.php index 3ea82b1e5..722dbfa8a 100644 --- a/Behavioral/Memento/Tests/MementoTest.php +++ b/Behavioral/Memento/Tests/MementoTest.php @@ -7,11 +7,10 @@ use DesignPatterns\Behavioral\Memento\Originator; /** - * MementoTest tests the memento pattern + * MementoTest tests the memento pattern. */ class MementoTest extends \PHPUnit_Framework_TestCase { - public function testUsageExample() { $originator = new Originator(); @@ -19,25 +18,25 @@ public function testUsageExample() $character = new \stdClass(); // new object - $character->name = "Gandalf"; + $character->name = 'Gandalf'; // connect Originator to character object $originator->setState($character); // work on the object - $character->name = "Gandalf the Grey"; + $character->name = 'Gandalf the Grey'; // still change something - $character->race = "Maia"; + $character->race = 'Maia'; // time to save state $snapshot = $originator->getStateAsMemento(); // put state to log $caretaker->saveToHistory($snapshot); // change something - $character->name = "Sauron"; + $character->name = 'Sauron'; // and again - $character->race = "Ainur"; + $character->race = 'Ainur'; // state inside the Originator was equally changed - $this->assertAttributeEquals($character, "state", $originator); + $this->assertAttributeEquals($character, 'state', $originator); // time to save another state $snapshot = $originator->getStateAsMemento(); @@ -51,32 +50,32 @@ public function testUsageExample() $character = $rollback->getState(); // yes, that what we need - $this->assertEquals("Gandalf the Grey", $character->name); + $this->assertEquals('Gandalf the Grey', $character->name); // make new changes - $character->name = "Gandalf the White"; + $character->name = 'Gandalf the White'; // and Originator linked to actual object again - $this->assertAttributeEquals($character, "state", $originator); + $this->assertAttributeEquals($character, 'state', $originator); } public function testStringState() { $originator = new Originator(); - $originator->setState("State1"); + $originator->setState('State1'); - $this->assertAttributeEquals("State1", "state", $originator); + $this->assertAttributeEquals('State1', 'state', $originator); - $originator->setState("State2"); - $this->assertAttributeEquals("State2", "state", $originator); + $originator->setState('State2'); + $this->assertAttributeEquals('State2', 'state', $originator); $snapshot = $originator->getStateAsMemento(); - $this->assertAttributeEquals("State2", "state", $snapshot); + $this->assertAttributeEquals('State2', 'state', $snapshot); - $originator->setState("State3"); - $this->assertAttributeEquals("State3", "state", $originator); + $originator->setState('State3'); + $this->assertAttributeEquals('State3', 'state', $originator); $originator->restoreFromMemento($snapshot); - $this->assertAttributeEquals("State2", "state", $originator); + $this->assertAttributeEquals('State2', 'state', $originator); } public function testSnapshotIsClone() @@ -88,11 +87,11 @@ public function testSnapshotIsClone() $snapshot = $originator->getStateAsMemento(); $object->new_property = 1; - $this->assertAttributeEquals($object, "state", $originator); - $this->assertAttributeNotEquals($object, "state", $snapshot); + $this->assertAttributeEquals($object, 'state', $originator); + $this->assertAttributeNotEquals($object, 'state', $snapshot); $originator->restoreFromMemento($snapshot); - $this->assertAttributeNotEquals($object, "state", $originator); + $this->assertAttributeNotEquals($object, 'state', $originator); } public function testCanChangeActualState() @@ -108,16 +107,16 @@ public function testCanChangeActualState() $first_state->first_property = 1; // just history $second_state->second_property = 2; - $this->assertAttributeEquals($first_state, "state", $originator); - $this->assertAttributeNotEquals($second_state, "state", $originator); + $this->assertAttributeEquals($first_state, 'state', $originator); + $this->assertAttributeNotEquals($second_state, 'state', $originator); $originator->restoreFromMemento($snapshot); // now it lost state $first_state->first_property = 11; // must be actual $second_state->second_property = 22; - $this->assertAttributeEquals($second_state, "state", $originator); - $this->assertAttributeNotEquals($first_state, "state", $originator); + $this->assertAttributeEquals($second_state, 'state', $originator); + $this->assertAttributeNotEquals($first_state, 'state', $originator); } public function testStateWithDifferentObjects() @@ -125,40 +124,39 @@ public function testStateWithDifferentObjects() $originator = new Originator(); $first = new \stdClass(); - $first->data = "foo"; + $first->data = 'foo'; $originator->setState($first); - $this->assertAttributeEquals($first, "state", $originator); + $this->assertAttributeEquals($first, 'state', $originator); $first_snapshot = $originator->getStateAsMemento(); - $this->assertAttributeEquals($first, "state", $first_snapshot); + $this->assertAttributeEquals($first, 'state', $first_snapshot); - $second = new \stdClass(); - $second->data = "bar"; + $second = new \stdClass(); + $second->data = 'bar'; $originator->setState($second); - $this->assertAttributeEquals($second, "state", $originator); + $this->assertAttributeEquals($second, 'state', $originator); $originator->restoreFromMemento($first_snapshot); - $this->assertAttributeEquals($first, "state", $originator); + $this->assertAttributeEquals($first, 'state', $originator); } public function testCaretaker() { $caretaker = new Caretaker(); - $memento1 = new Memento("foo"); - $memento2 = new Memento("bar"); + $memento1 = new Memento('foo'); + $memento2 = new Memento('bar'); $caretaker->saveToHistory($memento1); $caretaker->saveToHistory($memento2); - $this->assertAttributeEquals(array($memento1, $memento2), "history", $caretaker); + $this->assertAttributeEquals(array($memento1, $memento2), 'history', $caretaker); $this->assertEquals($memento1, $caretaker->getFromHistory(0)); $this->assertEquals($memento2, $caretaker->getFromHistory(1)); - } public function testCaretakerCustomLogic() { $caretaker = new Caretaker(); $result = $caretaker->runCustomLogic(); - $this->assertEquals("State3", $result); + $this->assertEquals('State3', $result); } } diff --git a/Behavioral/NullObject/LoggerInterface.php b/Behavioral/NullObject/LoggerInterface.php index 216d838d2..99a28c752 100644 --- a/Behavioral/NullObject/LoggerInterface.php +++ b/Behavioral/NullObject/LoggerInterface.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\NullObject; /** - * LoggerInterface is a contract for logging something + * LoggerInterface is a contract for logging something. * * Key feature: NullLogger MUST inherit from this interface like any other Loggers */ diff --git a/Behavioral/NullObject/PrintLogger.php b/Behavioral/NullObject/PrintLogger.php index a088145e4..371c1ab3a 100644 --- a/Behavioral/NullObject/PrintLogger.php +++ b/Behavioral/NullObject/PrintLogger.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\NullObject; /** - * PrintLogger is a logger that prints the log entry to standard output + * PrintLogger is a logger that prints the log entry to standard output. */ class PrintLogger implements LoggerInterface { diff --git a/Behavioral/NullObject/Service.php b/Behavioral/NullObject/Service.php index ae6d96da0..56a384723 100644 --- a/Behavioral/NullObject/Service.php +++ b/Behavioral/NullObject/Service.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\NullObject; /** - * Service is dummy service that uses a logger + * Service is dummy service that uses a logger. */ class Service { @@ -13,7 +13,7 @@ class Service protected $logger; /** - * we inject the logger in ctor and it is mandatory + * we inject the logger in ctor and it is mandatory. * * @param LoggerInterface $log */ @@ -28,7 +28,7 @@ public function __construct(LoggerInterface $log) public function doSomething() { // no more check "if (!is_null($this->logger))..." with the NullObject pattern - $this->logger->log('We are in ' . __METHOD__); + $this->logger->log('We are in '.__METHOD__); // something to do... } } diff --git a/Behavioral/NullObject/Tests/LoggerTest.php b/Behavioral/NullObject/Tests/LoggerTest.php index a8e7bf583..034b577bf 100644 --- a/Behavioral/NullObject/Tests/LoggerTest.php +++ b/Behavioral/NullObject/Tests/LoggerTest.php @@ -3,15 +3,14 @@ namespace DesignPatterns\Behavioral\NullObject\Tests; use DesignPatterns\Behavioral\NullObject\NullLogger; -use DesignPatterns\Behavioral\NullObject\Service; use DesignPatterns\Behavioral\NullObject\PrintLogger; +use DesignPatterns\Behavioral\NullObject\Service; /** - * LoggerTest tests for different loggers + * LoggerTest tests for different loggers. */ class LoggerTest extends \PHPUnit_Framework_TestCase { - public function testNullObject() { // one can use a singleton for NullObjet : I don't think it's a good idea diff --git a/Behavioral/Observer/Tests/ObserverTest.php b/Behavioral/Observer/Tests/ObserverTest.php index 75490cc7e..d9dacec27 100644 --- a/Behavioral/Observer/Tests/ObserverTest.php +++ b/Behavioral/Observer/Tests/ObserverTest.php @@ -2,15 +2,14 @@ namespace DesignPatterns\Behavioral\Observer\Tests; -use DesignPatterns\Behavioral\Observer\UserObserver; use DesignPatterns\Behavioral\Observer\User; +use DesignPatterns\Behavioral\Observer\UserObserver; /** - * ObserverTest tests the Observer pattern + * ObserverTest tests the Observer pattern. */ class ObserverTest extends \PHPUnit_Framework_TestCase { - protected $observer; protected function setUp() @@ -19,7 +18,7 @@ protected function setUp() } /** - * Tests the notification + * Tests the notification. */ public function testNotify() { @@ -31,7 +30,7 @@ public function testNotify() } /** - * Tests the subscribing + * Tests the subscribing. */ public function testAttachDetach() { @@ -53,7 +52,7 @@ public function testAttachDetach() } /** - * Tests the update() invocation on a mockup + * Tests the update() invocation on a mockup. */ public function testUpdateCalling() { diff --git a/Behavioral/Observer/User.php b/Behavioral/Observer/User.php index 213f22979..0d2a8171f 100644 --- a/Behavioral/Observer/User.php +++ b/Behavioral/Observer/User.php @@ -3,34 +3,33 @@ namespace DesignPatterns\Behavioral\Observer; /** - * Observer pattern : The observed object (the subject) + * Observer pattern : The observed object (the subject). * * The subject maintains a list of Observers and sends notifications. - * */ class User implements \SplSubject { /** - * user data + * user data. * * @var array */ protected $data = array(); /** - * observers + * observers. * * @var \SplObjectStorage */ protected $observers; - + public function __construct() { $this->observers = new \SplObjectStorage(); } /** - * attach a new observer + * attach a new observer. * * @param \SplObserver $observer * @@ -42,7 +41,7 @@ public function attach(\SplObserver $observer) } /** - * detach an observer + * detach an observer. * * @param \SplObserver $observer * @@ -54,7 +53,7 @@ public function detach(\SplObserver $observer) } /** - * notify observers + * notify observers. * * @return void */ @@ -68,7 +67,7 @@ public function notify() /** * Ideally one would better write setter/getter for all valid attributes and only call notify() - * on attributes that matter when changed + * on attributes that matter when changed. * * @param string $name * @param mixed $value diff --git a/Behavioral/Observer/UserObserver.php b/Behavioral/Observer/UserObserver.php index f444604d0..f2673bacc 100644 --- a/Behavioral/Observer/UserObserver.php +++ b/Behavioral/Observer/UserObserver.php @@ -3,18 +3,18 @@ namespace DesignPatterns\Behavioral\Observer; /** - * class UserObserver + * class UserObserver. */ class UserObserver implements \SplObserver { /** * This is the only method to implement as an observer. - * It is called by the Subject (usually by SplSubject::notify() ) + * It is called by the Subject (usually by SplSubject::notify() ). * * @param \SplSubject $subject */ public function update(\SplSubject $subject) { - echo get_class($subject) . ' has been updated'; + echo get_class($subject).' has been updated'; } } diff --git a/Behavioral/Specification/AbstractSpecification.php b/Behavioral/Specification/AbstractSpecification.php index f2975396d..66d61b8c3 100644 --- a/Behavioral/Specification/AbstractSpecification.php +++ b/Behavioral/Specification/AbstractSpecification.php @@ -1,13 +1,14 @@ comparator) { - throw new \LogicException("Comparator is not set"); + throw new \LogicException('Comparator is not set'); } $callback = array($this->comparator, 'compare'); diff --git a/Behavioral/Strategy/Tests/StrategyTest.php b/Behavioral/Strategy/Tests/StrategyTest.php index 4831b182f..1911ba406 100644 --- a/Behavioral/Strategy/Tests/StrategyTest.php +++ b/Behavioral/Strategy/Tests/StrategyTest.php @@ -8,21 +8,20 @@ use DesignPatterns\Behavioral\Strategy\Strategy; /** - * Tests for Strategy pattern + * Tests for Strategy pattern. */ class StrategyTest extends \PHPUnit_Framework_TestCase { - public function getIdCollection() { return array( array( array(array('id' => 2), array('id' => 1), array('id' => 3)), - array('id' => 1) + array('id' => 1), ), array( array(array('id' => 3), array('id' => 2), array('id' => 1)), - array('id' => 1) + array('id' => 1), ), ); } @@ -32,11 +31,11 @@ public function getDateCollection() return array( array( array(array('date' => '2014-03-03'), array('date' => '2015-03-02'), array('date' => '2013-03-01')), - array('date' => '2013-03-01') + array('date' => '2013-03-01'), ), array( array(array('date' => '2014-02-03'), array('date' => '2013-02-01'), array('date' => '2015-02-02')), - array('date' => '2013-02-01') + array('date' => '2013-02-01'), ), ); } diff --git a/Behavioral/TemplateMethod/BeachJourney.php b/Behavioral/TemplateMethod/BeachJourney.php index 94018f3e3..d19845c31 100644 --- a/Behavioral/TemplateMethod/BeachJourney.php +++ b/Behavioral/TemplateMethod/BeachJourney.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Behavioral\TemplateMethod; /** - * BeachJourney is vacation at the beach + * BeachJourney is vacation at the beach. */ class BeachJourney extends Journey { /** - * prints what to do to enjoy your vacation + * prints what to do to enjoy your vacation. */ protected function enjoyVacation() { diff --git a/Behavioral/TemplateMethod/CityJourney.php b/Behavioral/TemplateMethod/CityJourney.php index 89c2ef0e5..3f36b61e4 100644 --- a/Behavioral/TemplateMethod/CityJourney.php +++ b/Behavioral/TemplateMethod/CityJourney.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Behavioral\TemplateMethod; /** - * CityJourney is a journey in a city + * CityJourney is a journey in a city. */ class CityJourney extends Journey { /** - * prints what to do in your journey to enjoy vacation + * prints what to do in your journey to enjoy vacation. */ protected function enjoyVacation() { diff --git a/Behavioral/TemplateMethod/Journey.php b/Behavioral/TemplateMethod/Journey.php index cec9a7daf..6309e7fb4 100644 --- a/Behavioral/TemplateMethod/Journey.php +++ b/Behavioral/TemplateMethod/Journey.php @@ -23,7 +23,7 @@ final public function takeATrip() } /** - * This method must be implemented, this is the key-feature of this pattern + * This method must be implemented, this is the key-feature of this pattern. */ abstract protected function enjoyVacation(); @@ -37,7 +37,7 @@ protected function buyGift() } /** - * This method will be unknown by subclasses (better) + * This method will be unknown by subclasses (better). */ private function buyAFlight() { @@ -46,7 +46,7 @@ private function buyAFlight() /** * Subclasses will get access to this method but cannot override it and - * compromise this algorithm (warning : cause of cyclic dependencies) + * compromise this algorithm (warning : cause of cyclic dependencies). */ final protected function takePlane() { diff --git a/Behavioral/TemplateMethod/Tests/JourneyTest.php b/Behavioral/TemplateMethod/Tests/JourneyTest.php index d0b134c6c..82acef3cf 100644 --- a/Behavioral/TemplateMethod/Tests/JourneyTest.php +++ b/Behavioral/TemplateMethod/Tests/JourneyTest.php @@ -5,11 +5,10 @@ use DesignPatterns\Behavioral\TemplateMethod; /** - * JourneyTest tests all journeys + * JourneyTest tests all journeys. */ class JourneyTest extends \PHPUnit_Framework_TestCase { - public function testBeach() { $journey = new TemplateMethod\BeachJourney(); @@ -25,7 +24,7 @@ public function testCity() } /** - * How to test an abstract template method with PHPUnit + * How to test an abstract template method with PHPUnit. */ public function testLasVegas() { diff --git a/Behavioral/Visitor/Group.php b/Behavioral/Visitor/Group.php index 3990f9cd0..b2c9d900e 100644 --- a/Behavioral/Visitor/Group.php +++ b/Behavioral/Visitor/Group.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\Visitor; /** - * An example of a Visitor: Group + * An example of a Visitor: Group. */ class Group extends Role { @@ -25,6 +25,6 @@ public function __construct($name) */ public function getName() { - return "Group: " . $this->name; + return 'Group: '.$this->name; } } diff --git a/Behavioral/Visitor/Role.php b/Behavioral/Visitor/Role.php index fd0d0a414..011a0fb77 100644 --- a/Behavioral/Visitor/Role.php +++ b/Behavioral/Visitor/Role.php @@ -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 @@ public function accept(RoleVisitorInterface $visitor) // 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"); } diff --git a/Behavioral/Visitor/RolePrintVisitor.php b/Behavioral/Visitor/RolePrintVisitor.php index 5f07d5c81..49777cf97 100644 --- a/Behavioral/Visitor/RolePrintVisitor.php +++ b/Behavioral/Visitor/RolePrintVisitor.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\Visitor; /** - * Visitor Pattern + * Visitor Pattern. * * An implementation of a concrete Visitor */ @@ -14,7 +14,7 @@ class RolePrintVisitor implements RoleVisitorInterface */ public function visitGroup(Group $role) { - echo "Role: " . $role->getName(); + echo 'Role: '.$role->getName(); } /** @@ -22,6 +22,6 @@ public function visitGroup(Group $role) */ public function visitUser(User $role) { - echo "Role: " . $role->getName(); + echo 'Role: '.$role->getName(); } } diff --git a/Behavioral/Visitor/RoleVisitorInterface.php b/Behavioral/Visitor/RoleVisitorInterface.php index b007b13ca..1a72d7e99 100644 --- a/Behavioral/Visitor/RoleVisitorInterface.php +++ b/Behavioral/Visitor/RoleVisitorInterface.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\Visitor; /** - * Visitor Pattern + * Visitor Pattern. * * The contract for the visitor. * @@ -16,14 +16,14 @@ interface RoleVisitorInterface { /** - * Visit a User object + * Visit a User object. * * @param \DesignPatterns\Behavioral\Visitor\User $role */ public function visitUser(User $role); /** - * Visit a Group object + * Visit a Group object. * * @param \DesignPatterns\Behavioral\Visitor\Group $role */ diff --git a/Behavioral/Visitor/Tests/VisitorTest.php b/Behavioral/Visitor/Tests/VisitorTest.php index 6d71658ea..f3b5bc7c8 100644 --- a/Behavioral/Visitor/Tests/VisitorTest.php +++ b/Behavioral/Visitor/Tests/VisitorTest.php @@ -5,11 +5,10 @@ use DesignPatterns\Behavioral\Visitor; /** - * VisitorTest tests the visitor pattern + * VisitorTest tests the visitor pattern. */ class VisitorTest extends \PHPUnit_Framework_TestCase { - protected $visitor; protected function setUp() @@ -20,8 +19,8 @@ protected function setUp() public function getRole() { return array( - array(new Visitor\User("Dominik"), 'Role: User Dominik'), - array(new Visitor\Group("Administrators"), 'Role: Group: Administrators') + array(new Visitor\User('Dominik'), 'Role: User Dominik'), + array(new Visitor\Group('Administrators'), 'Role: Group: Administrators'), ); } diff --git a/Behavioral/Visitor/User.php b/Behavioral/Visitor/User.php index e0cc4c72b..5a95fbe3f 100644 --- a/Behavioral/Visitor/User.php +++ b/Behavioral/Visitor/User.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Behavioral\Visitor; /** - * Visitor Pattern + * Visitor Pattern. * * One example for a visitee. Each visitee has to extends Role */ @@ -27,6 +27,6 @@ public function __construct($name) */ public function getName() { - return "User " . $this->name; + return 'User '.$this->name; } } diff --git a/Creational/AbstractFactory/AbstractFactory.php b/Creational/AbstractFactory/AbstractFactory.php index 49982e5d3..6529ff67a 100644 --- a/Creational/AbstractFactory/AbstractFactory.php +++ b/Creational/AbstractFactory/AbstractFactory.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\AbstractFactory; /** - * class AbstractFactory + * class AbstractFactory. * * Sometimes also known as "Kit" in a GUI libraries. * @@ -20,7 +20,7 @@ abstract class AbstractFactory { /** - * Creates a text component + * Creates a text component. * * @param string $content * @@ -29,7 +29,7 @@ abstract class AbstractFactory abstract public function createText($content); /** - * Creates a picture component + * Creates a picture component. * * @param string $path * @param string $name diff --git a/Creational/AbstractFactory/Html/Picture.php b/Creational/AbstractFactory/Html/Picture.php index 9d7f44041..3abacb484 100644 --- a/Creational/AbstractFactory/Html/Picture.php +++ b/Creational/AbstractFactory/Html/Picture.php @@ -5,14 +5,14 @@ use DesignPatterns\Creational\AbstractFactory\Picture as BasePicture; /** - * Class Picture + * Class Picture. * * Picture is a concrete image for HTML rendering */ class Picture extends BasePicture { /** - * some crude rendering from HTML output + * some crude rendering from HTML output. * * @return string */ diff --git a/Creational/AbstractFactory/Html/Text.php b/Creational/AbstractFactory/Html/Text.php index 120c043a2..8c33da629 100644 --- a/Creational/AbstractFactory/Html/Text.php +++ b/Creational/AbstractFactory/Html/Text.php @@ -5,19 +5,19 @@ use DesignPatterns\Creational\AbstractFactory\Text as BaseText; /** - * Class Text + * Class Text. * * Text is a concrete text for HTML rendering */ class Text extends BaseText { /** - * some crude rendering from HTML output + * some crude rendering from HTML output. * * @return string */ public function render() { - return '
' . htmlspecialchars($this->text) . '
'; + return '
'.htmlspecialchars($this->text).'
'; } } diff --git a/Creational/AbstractFactory/HtmlFactory.php b/Creational/AbstractFactory/HtmlFactory.php index 7982a24ed..5c22859ea 100644 --- a/Creational/AbstractFactory/HtmlFactory.php +++ b/Creational/AbstractFactory/HtmlFactory.php @@ -3,14 +3,14 @@ namespace DesignPatterns\Creational\AbstractFactory; /** - * Class HtmlFactory + * Class HtmlFactory. * * HtmlFactory is a concrete factory for HTML component */ class HtmlFactory extends AbstractFactory { /** - * Creates a picture component + * Creates a picture component. * * @param string $path * @param string $name @@ -23,7 +23,7 @@ public function createPicture($path, $name = '') } /** - * Creates a text component + * Creates a text component. * * @param string $content * diff --git a/Creational/AbstractFactory/Json/Picture.php b/Creational/AbstractFactory/Json/Picture.php index 13d191b01..77bb150eb 100644 --- a/Creational/AbstractFactory/Json/Picture.php +++ b/Creational/AbstractFactory/Json/Picture.php @@ -5,14 +5,14 @@ use DesignPatterns\Creational\AbstractFactory\Picture as BasePicture; /** - * Class Picture + * Class Picture. * * Picture is a concrete image for JSON rendering */ class Picture extends BasePicture { /** - * some crude rendering from JSON output + * some crude rendering from JSON output. * * @return string */ diff --git a/Creational/AbstractFactory/Json/Text.php b/Creational/AbstractFactory/Json/Text.php index 699fff3ab..4c51785d5 100644 --- a/Creational/AbstractFactory/Json/Text.php +++ b/Creational/AbstractFactory/Json/Text.php @@ -5,14 +5,14 @@ use DesignPatterns\Creational\AbstractFactory\Text as BaseText; /** - * Class Text + * Class Text. * * Text is a text component with a JSON rendering */ class Text extends BaseText { /** - * some crude rendering from JSON output + * some crude rendering from JSON output. * * @return string */ diff --git a/Creational/AbstractFactory/JsonFactory.php b/Creational/AbstractFactory/JsonFactory.php index ab2bb6fb2..63a997914 100644 --- a/Creational/AbstractFactory/JsonFactory.php +++ b/Creational/AbstractFactory/JsonFactory.php @@ -3,16 +3,15 @@ namespace DesignPatterns\Creational\AbstractFactory; /** - * Class JsonFactory + * Class JsonFactory. * * JsonFactory is a factory for creating a family of JSON component * (example for ajax) */ class JsonFactory extends AbstractFactory { - /** - * Creates a picture component + * Creates a picture component. * * @param string $path * @param string $name @@ -25,7 +24,7 @@ public function createPicture($path, $name = '') } /** - * Creates a text component + * Creates a text component. * * @param string $content * diff --git a/Creational/AbstractFactory/MediaInterface.php b/Creational/AbstractFactory/MediaInterface.php index 6bb5d3ab3..aa73f1be6 100644 --- a/Creational/AbstractFactory/MediaInterface.php +++ b/Creational/AbstractFactory/MediaInterface.php @@ -3,16 +3,15 @@ namespace DesignPatterns\Creational\AbstractFactory; /** - * Interface MediaInterface + * Interface MediaInterface. * * This contract is not part of the pattern, in general case, each component * are not related */ interface MediaInterface { - /** - * some crude rendering from JSON or html output (depended on concrete class) + * some crude rendering from JSON or html output (depended on concrete class). * * @return string */ diff --git a/Creational/AbstractFactory/Picture.php b/Creational/AbstractFactory/Picture.php index 8a4f7202d..89fd66f22 100644 --- a/Creational/AbstractFactory/Picture.php +++ b/Creational/AbstractFactory/Picture.php @@ -3,11 +3,10 @@ namespace DesignPatterns\Creational\AbstractFactory; /** - * Class Picture + * Class Picture. */ abstract class Picture implements MediaInterface { - /** * @var string */ diff --git a/Creational/AbstractFactory/Tests/AbstractFactoryTest.php b/Creational/AbstractFactory/Tests/AbstractFactoryTest.php index b51394a80..97f441760 100644 --- a/Creational/AbstractFactory/Tests/AbstractFactoryTest.php +++ b/Creational/AbstractFactory/Tests/AbstractFactoryTest.php @@ -7,7 +7,7 @@ use DesignPatterns\Creational\AbstractFactory\JsonFactory; /** - * AbstractFactoryTest tests concrete factories + * AbstractFactoryTest tests concrete factories. */ class AbstractFactoryTest extends \PHPUnit_Framework_TestCase { @@ -15,7 +15,7 @@ public function getFactories() { return array( array(new JsonFactory()), - array(new HtmlFactory()) + array(new HtmlFactory()), ); } @@ -31,7 +31,7 @@ public function testComponentCreation(AbstractFactory $factory) $article = array( $factory->createText('Lorem Ipsum'), $factory->createPicture('/image.jpg', 'caption'), - $factory->createText('footnotes') + $factory->createText('footnotes'), ); $this->assertContainsOnly('DesignPatterns\Creational\AbstractFactory\MediaInterface', $article); diff --git a/Creational/AbstractFactory/Text.php b/Creational/AbstractFactory/Text.php index 5d2da89d2..30984f35a 100644 --- a/Creational/AbstractFactory/Text.php +++ b/Creational/AbstractFactory/Text.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\AbstractFactory; /** - * Class Text + * Class Text. */ abstract class Text implements MediaInterface { diff --git a/Creational/Builder/BikeBuilder.php b/Creational/Builder/BikeBuilder.php index 53d53d3a8..f83c5db6a 100644 --- a/Creational/Builder/BikeBuilder.php +++ b/Creational/Builder/BikeBuilder.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Builder; /** - * BikeBuilder builds bike + * BikeBuilder builds bike. */ class BikeBuilder implements BuilderInterface { diff --git a/Creational/Builder/CarBuilder.php b/Creational/Builder/CarBuilder.php index 772517669..a0693d0db 100644 --- a/Creational/Builder/CarBuilder.php +++ b/Creational/Builder/CarBuilder.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Builder; /** - * CarBuilder builds car + * CarBuilder builds car. */ class CarBuilder implements BuilderInterface { diff --git a/Creational/Builder/Director.php b/Creational/Builder/Director.php index 3d125d9be..642cd1b78 100644 --- a/Creational/Builder/Director.php +++ b/Creational/Builder/Director.php @@ -10,9 +10,8 @@ */ class Director { - /** - * The director don't know about concrete part + * The director don't know about concrete part. * * @param BuilderInterface $builder * diff --git a/Creational/Builder/Parts/Bike.php b/Creational/Builder/Parts/Bike.php index 6efefe940..e5adbba5b 100644 --- a/Creational/Builder/Parts/Bike.php +++ b/Creational/Builder/Parts/Bike.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Builder\Parts; /** - * Bike is a bike + * Bike is a bike. */ class Bike extends Vehicle { diff --git a/Creational/Builder/Parts/Car.php b/Creational/Builder/Parts/Car.php index 1d4496c04..e345ea9aa 100644 --- a/Creational/Builder/Parts/Car.php +++ b/Creational/Builder/Parts/Car.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Builder\Parts; /** - * Car is a car + * Car is a car. */ class Car extends Vehicle { diff --git a/Creational/Builder/Parts/Door.php b/Creational/Builder/Parts/Door.php index 526d41b96..fc12608cd 100644 --- a/Creational/Builder/Parts/Door.php +++ b/Creational/Builder/Parts/Door.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Builder\Parts; /** - * Class Door + * Class Door. */ class Door { diff --git a/Creational/Builder/Parts/Engine.php b/Creational/Builder/Parts/Engine.php index 0b2fad0f6..5232ab383 100644 --- a/Creational/Builder/Parts/Engine.php +++ b/Creational/Builder/Parts/Engine.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Builder\Parts; /** - * Class Engine + * Class Engine. */ class Engine { diff --git a/Creational/Builder/Parts/Vehicle.php b/Creational/Builder/Parts/Vehicle.php index 492eadea2..487be57ac 100644 --- a/Creational/Builder/Parts/Vehicle.php +++ b/Creational/Builder/Parts/Vehicle.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Builder\Parts; /** - * VehicleInterface is a contract for a vehicle + * VehicleInterface is a contract for a vehicle. */ abstract class Vehicle { diff --git a/Creational/Builder/Parts/Wheel.php b/Creational/Builder/Parts/Wheel.php index 7fb60fdce..0a1afbdfe 100644 --- a/Creational/Builder/Parts/Wheel.php +++ b/Creational/Builder/Parts/Wheel.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Builder\Parts; /** - * Class Wheel + * Class Wheel. */ class Wheel { diff --git a/Creational/Builder/Tests/DirectorTest.php b/Creational/Builder/Tests/DirectorTest.php index 0520bfe21..9f07b8306 100644 --- a/Creational/Builder/Tests/DirectorTest.php +++ b/Creational/Builder/Tests/DirectorTest.php @@ -2,17 +2,16 @@ namespace DesignPatterns\Creational\Builder\Tests; -use DesignPatterns\Creational\Builder\Director; -use DesignPatterns\Creational\Builder\CarBuilder; use DesignPatterns\Creational\Builder\BikeBuilder; use DesignPatterns\Creational\Builder\BuilderInterface; +use DesignPatterns\Creational\Builder\CarBuilder; +use DesignPatterns\Creational\Builder\Director; /** - * DirectorTest tests the builder pattern + * DirectorTest tests the builder pattern. */ class DirectorTest extends \PHPUnit_Framework_TestCase { - protected $director; protected function setUp() @@ -24,7 +23,7 @@ public function getBuilder() { return array( array(new CarBuilder()), - array(new BikeBuilder()) + array(new BikeBuilder()), ); } diff --git a/Creational/FactoryMethod/Bicycle.php b/Creational/FactoryMethod/Bicycle.php index 01fa8a0a3..8e41f8891 100644 --- a/Creational/FactoryMethod/Bicycle.php +++ b/Creational/FactoryMethod/Bicycle.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\FactoryMethod; /** - * Bicycle is a bicycle + * Bicycle is a bicycle. */ class Bicycle implements VehicleInterface { @@ -13,7 +13,7 @@ class Bicycle implements VehicleInterface protected $color; /** - * sets the color of the bicycle + * sets the color of the bicycle. * * @param string $rgb */ diff --git a/Creational/FactoryMethod/FactoryMethod.php b/Creational/FactoryMethod/FactoryMethod.php index dd24b1565..fa3d4a3a6 100644 --- a/Creational/FactoryMethod/FactoryMethod.php +++ b/Creational/FactoryMethod/FactoryMethod.php @@ -3,16 +3,15 @@ namespace DesignPatterns\Creational\FactoryMethod; /** - * class FactoryMethod + * class FactoryMethod. */ abstract class FactoryMethod { - const CHEAP = 1; const FAST = 2; /** - * The children of the class must implement this method + * The children of the class must implement this method. * * Sometimes this method can be public to get "raw" object * @@ -23,7 +22,7 @@ abstract class FactoryMethod abstract protected function createVehicle($type); /** - * Creates a new vehicle + * Creates a new vehicle. * * @param int $type * @@ -32,7 +31,7 @@ abstract protected function createVehicle($type); public function create($type) { $obj = $this->createVehicle($type); - $obj->setColor("#f00"); + $obj->setColor('#f00'); return $obj; } diff --git a/Creational/FactoryMethod/Ferrari.php b/Creational/FactoryMethod/Ferrari.php index c905f918e..9434e3d6e 100644 --- a/Creational/FactoryMethod/Ferrari.php +++ b/Creational/FactoryMethod/Ferrari.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\FactoryMethod; /** - * Ferrari is a italian car + * Ferrari is a italian car. */ class Ferrari implements VehicleInterface { diff --git a/Creational/FactoryMethod/GermanFactory.php b/Creational/FactoryMethod/GermanFactory.php index 67306e9aa..1f65eb4c9 100644 --- a/Creational/FactoryMethod/GermanFactory.php +++ b/Creational/FactoryMethod/GermanFactory.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\FactoryMethod; /** - * GermanFactory is a vehicle factory in Germany + * GermanFactory is a vehicle factory in Germany. */ class GermanFactory extends FactoryMethod { diff --git a/Creational/FactoryMethod/ItalianFactory.php b/Creational/FactoryMethod/ItalianFactory.php index c7010e0ca..25eeaf16e 100644 --- a/Creational/FactoryMethod/ItalianFactory.php +++ b/Creational/FactoryMethod/ItalianFactory.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\FactoryMethod; /** - * ItalianFactory is vehicle factory in Italy + * ItalianFactory is vehicle factory in Italy. */ class ItalianFactory extends FactoryMethod { diff --git a/Creational/FactoryMethod/Porsche.php b/Creational/FactoryMethod/Porsche.php index cba25ce86..bdabb8758 100644 --- a/Creational/FactoryMethod/Porsche.php +++ b/Creational/FactoryMethod/Porsche.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\FactoryMethod; /** - * Porsche is a german car + * Porsche is a german car. */ class Porsche implements VehicleInterface { diff --git a/Creational/FactoryMethod/Tests/FactoryMethodTest.php b/Creational/FactoryMethod/Tests/FactoryMethodTest.php index acbe0c648..6b1c4d295 100644 --- a/Creational/FactoryMethod/Tests/FactoryMethodTest.php +++ b/Creational/FactoryMethod/Tests/FactoryMethodTest.php @@ -7,21 +7,20 @@ use DesignPatterns\Creational\FactoryMethod\ItalianFactory; /** - * FactoryMethodTest tests the factory method pattern + * FactoryMethodTest tests the factory method pattern. */ class FactoryMethodTest extends \PHPUnit_Framework_TestCase { - protected $type = array( FactoryMethod::CHEAP, - FactoryMethod::FAST + FactoryMethod::FAST, ); public function getShop() { return array( array(new GermanFactory()), - array(new ItalianFactory()) + array(new ItalianFactory()), ); } diff --git a/Creational/FactoryMethod/VehicleInterface.php b/Creational/FactoryMethod/VehicleInterface.php index a734b612f..ccb05eebb 100644 --- a/Creational/FactoryMethod/VehicleInterface.php +++ b/Creational/FactoryMethod/VehicleInterface.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Creational\FactoryMethod; /** - * VehicleInterface is a contract for a vehicle + * VehicleInterface is a contract for a vehicle. */ interface VehicleInterface { /** - * sets the color of the vehicle + * sets the color of the vehicle. * * @param string $rgb */ diff --git a/Creational/Multiton/Multiton.php b/Creational/Multiton/Multiton.php index 44f1ef07e..5338e6255 100644 --- a/Creational/Multiton/Multiton.php +++ b/Creational/Multiton/Multiton.php @@ -3,24 +3,22 @@ namespace DesignPatterns\Creational\Multiton; /** - * class Multiton + * class Multiton. */ class Multiton { /** - * - * the first instance + * the first instance. */ const INSTANCE_1 = '1'; /** - * - * the second instance + * the second instance. */ const INSTANCE_2 = '2'; /** - * holds the named instances + * holds the named instances. * * @var array */ @@ -28,7 +26,6 @@ class Multiton /** * should not be called from outside: private! - * */ private function __construct() { @@ -36,7 +33,7 @@ private function __construct() /** * gets the instance with the given name, e.g. Multiton::INSTANCE_1 - * uses lazy initialization + * uses lazy initialization. * * @param string $instanceName * @@ -52,7 +49,7 @@ public static function getInstance($instanceName) } /** - * prevent instance from being cloned + * prevent instance from being cloned. * * @return void */ @@ -61,7 +58,7 @@ private function __clone() } /** - * prevent instance from being unserialized + * prevent instance from being unserialized. * * @return void */ diff --git a/Creational/Pool/Pool.php b/Creational/Pool/Pool.php index e3a809b49..7dcc6e320 100644 --- a/Creational/Pool/Pool.php +++ b/Creational/Pool/Pool.php @@ -4,7 +4,6 @@ class Pool { - private $instances = array(); private $class; diff --git a/Creational/Pool/Processor.php b/Creational/Pool/Processor.php index 957e91ff6..89179b92f 100644 --- a/Creational/Pool/Processor.php +++ b/Creational/Pool/Processor.php @@ -4,11 +4,10 @@ class Processor { - private $pool; private $processing = 0; private $maxProcesses = 3; - private $waitingQueue = []; + private $waitingQueue = array(); public function __construct(Pool $pool) { diff --git a/Creational/Pool/Worker.php b/Creational/Pool/Worker.php index acdc1bafd..08d76b8a8 100644 --- a/Creational/Pool/Worker.php +++ b/Creational/Pool/Worker.php @@ -4,7 +4,6 @@ class Worker { - public function __construct() { // let's say that constuctor does really expensive work... diff --git a/Creational/Prototype/BarBookPrototype.php b/Creational/Prototype/BarBookPrototype.php index 4354a6045..7c9b72b3e 100644 --- a/Creational/Prototype/BarBookPrototype.php +++ b/Creational/Prototype/BarBookPrototype.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Prototype; /** - * Class BarBookPrototype + * Class BarBookPrototype. */ class BarBookPrototype extends BookPrototype { @@ -13,7 +13,7 @@ class BarBookPrototype extends BookPrototype protected $category = 'Bar'; /** - * empty clone + * empty clone. */ public function __clone() { diff --git a/Creational/Prototype/BookPrototype.php b/Creational/Prototype/BookPrototype.php index 18d48713a..e0fafa62e 100644 --- a/Creational/Prototype/BookPrototype.php +++ b/Creational/Prototype/BookPrototype.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\Prototype; /** - * class BookPrototype + * class BookPrototype. */ abstract class BookPrototype { @@ -19,6 +19,7 @@ abstract class BookPrototype /** * @abstract + * * @return void */ abstract public function __clone(); diff --git a/Creational/Prototype/FooBookPrototype.php b/Creational/Prototype/FooBookPrototype.php index 9707bfd42..95ea9e67c 100644 --- a/Creational/Prototype/FooBookPrototype.php +++ b/Creational/Prototype/FooBookPrototype.php @@ -3,14 +3,14 @@ namespace DesignPatterns\Creational\Prototype; /** - * Class FooBookPrototype + * Class FooBookPrototype. */ class FooBookPrototype extends BookPrototype { protected $category = 'Foo'; /** - * empty clone + * empty clone. */ public function __clone() { diff --git a/Creational/Prototype/index.php b/Creational/Prototype/index.php index f268e5c60..d0f6e9473 100644 --- a/Creational/Prototype/index.php +++ b/Creational/Prototype/index.php @@ -8,10 +8,10 @@ // now lets say we need 10,000 books of foo and 5,000 of bar ... for ($i = 0; $i < 10000; $i++) { $book = clone $fooPrototype; - $book->setTitle('Foo Book No ' . $i); + $book->setTitle('Foo Book No '.$i); } for ($i = 0; $i < 5000; $i++) { $book = clone $barPrototype; - $book->setTitle('Bar Book No ' . $i); + $book->setTitle('Bar Book No '.$i); } diff --git a/Creational/SimpleFactory/Bicycle.php b/Creational/SimpleFactory/Bicycle.php index 67215f185..defa8014c 100644 --- a/Creational/SimpleFactory/Bicycle.php +++ b/Creational/SimpleFactory/Bicycle.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\SimpleFactory; /** - * Bicycle is a bicycle + * Bicycle is a bicycle. */ class Bicycle implements VehicleInterface { diff --git a/Creational/SimpleFactory/ConcreteFactory.php b/Creational/SimpleFactory/ConcreteFactory.php index dd8acf8b4..5f4cd2d4a 100644 --- a/Creational/SimpleFactory/ConcreteFactory.php +++ b/Creational/SimpleFactory/ConcreteFactory.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\SimpleFactory; /** - * class ConcreteFactory + * class ConcreteFactory. */ class ConcreteFactory { @@ -19,18 +19,19 @@ class ConcreteFactory public function __construct() { $this->typeList = array( - 'bicycle' => __NAMESPACE__ . '\Bicycle', - 'other' => __NAMESPACE__ . '\Scooter' + 'bicycle' => __NAMESPACE__.'\Bicycle', + 'other' => __NAMESPACE__.'\Scooter', ); } /** - * Creates a vehicle + * Creates a vehicle. * * @param string $type a known type key * - * @return VehicleInterface a new instance of VehicleInterface * @throws \InvalidArgumentException + * + * @return VehicleInterface a new instance of VehicleInterface */ public function createVehicle($type) { diff --git a/Creational/SimpleFactory/Scooter.php b/Creational/SimpleFactory/Scooter.php index 81fa50566..e1db7348b 100644 --- a/Creational/SimpleFactory/Scooter.php +++ b/Creational/SimpleFactory/Scooter.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\SimpleFactory; /** - * Scooter is a Scooter + * Scooter is a Scooter. */ class Scooter implements VehicleInterface { diff --git a/Creational/SimpleFactory/Tests/SimpleFactoryTest.php b/Creational/SimpleFactory/Tests/SimpleFactoryTest.php index 1fffda3e7..c913d9659 100644 --- a/Creational/SimpleFactory/Tests/SimpleFactoryTest.php +++ b/Creational/SimpleFactory/Tests/SimpleFactoryTest.php @@ -5,11 +5,10 @@ use DesignPatterns\Creational\SimpleFactory\ConcreteFactory; /** - * SimpleFactoryTest tests the Simple Factory pattern + * SimpleFactoryTest tests the Simple Factory pattern. */ class SimpleFactoryTest extends \PHPUnit_Framework_TestCase { - protected $factory; protected function setUp() @@ -21,7 +20,7 @@ public function getType() { return array( array('bicycle'), - array('other') + array('other'), ); } diff --git a/Creational/SimpleFactory/VehicleInterface.php b/Creational/SimpleFactory/VehicleInterface.php index eb13a6689..f2c8d3f41 100644 --- a/Creational/SimpleFactory/VehicleInterface.php +++ b/Creational/SimpleFactory/VehicleInterface.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\SimpleFactory; /** - * VehicleInterface is a contract for a vehicle + * VehicleInterface is a contract for a vehicle. */ interface VehicleInterface { diff --git a/Creational/Singleton/Singleton.php b/Creational/Singleton/Singleton.php index 94f7a0a73..650810ee6 100644 --- a/Creational/Singleton/Singleton.php +++ b/Creational/Singleton/Singleton.php @@ -2,10 +2,8 @@ namespace DesignPatterns\Creational\Singleton; -use DesignPatterns\Creational\Singleton\SingletonPatternViolationException; - /** - * class Singleton + * class Singleton. */ class Singleton { @@ -13,16 +11,16 @@ class Singleton * @var Singleton reference to singleton instance */ private static $instance; - + /** - * gets the instance via lazy initialization (created on first usage) + * gets the instance via lazy initialization (created on first usage). * * @return self */ public static function getInstance() { if (null === static::$instance) { - static::$instance = new static; + static::$instance = new static(); } return static::$instance; @@ -30,28 +28,31 @@ public static function getInstance() /** * is not allowed to call from outside: private! - * */ private function __construct() { } /** - * prevent the instance from being cloned + * prevent the instance from being cloned. + * * @throws SingletonPatternViolationException + * * @return void */ - public final function __clone() + final public function __clone() { throw new SingletonPatternViolationException('This is a Singleton. Clone is forbidden'); } /** - * prevent from being unserialized + * prevent from being unserialized. + * * @throws SingletonPatternViolationException + * * @return void */ - public final function __wakeup() + final public function __wakeup() { throw new SingletonPatternViolationException('This is a Singleton. __wakeup usage is forbidden'); } diff --git a/Creational/Singleton/SingletonPatternViolationException.php b/Creational/Singleton/SingletonPatternViolationException.php index 38be5e6ad..b025b4ac6 100644 --- a/Creational/Singleton/SingletonPatternViolationException.php +++ b/Creational/Singleton/SingletonPatternViolationException.php @@ -4,5 +4,4 @@ class SingletonPatternViolationException extends \Exception { - } diff --git a/Creational/Singleton/Tests/SingletonTest.php b/Creational/Singleton/Tests/SingletonTest.php index 122d4dc05..6b72285b6 100644 --- a/Creational/Singleton/Tests/SingletonTest.php +++ b/Creational/Singleton/Tests/SingletonTest.php @@ -5,11 +5,10 @@ use DesignPatterns\Creational\Singleton\Singleton; /** - * SingletonTest tests the singleton pattern + * SingletonTest tests the singleton pattern. */ class SingletonTest extends \PHPUnit_Framework_TestCase { - public function testUniqueness() { $firstCall = Singleton::getInstance(); @@ -29,6 +28,7 @@ public function testNoConstructor() /** * @expectedException \DesignPatterns\Creational\Singleton\SingletonPatternViolationException + * * @return void */ public function testNoCloneAllowed() @@ -39,6 +39,7 @@ public function testNoCloneAllowed() /** * @expectedException \DesignPatterns\Creational\Singleton\SingletonPatternViolationException + * * @return void */ public function testNoSerializationAllowed() diff --git a/Creational/StaticFactory/FormatNumber.php b/Creational/StaticFactory/FormatNumber.php index 8f382f703..e577ab243 100644 --- a/Creational/StaticFactory/FormatNumber.php +++ b/Creational/StaticFactory/FormatNumber.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\StaticFactory; /** - * Class FormatNumber + * Class FormatNumber. */ class FormatNumber implements FormatterInterface { diff --git a/Creational/StaticFactory/FormatString.php b/Creational/StaticFactory/FormatString.php index a0d174d94..5cb9e2878 100644 --- a/Creational/StaticFactory/FormatString.php +++ b/Creational/StaticFactory/FormatString.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\StaticFactory; /** - * Class FormatString + * Class FormatString. */ class FormatString implements FormatterInterface { diff --git a/Creational/StaticFactory/FormatterInterface.php b/Creational/StaticFactory/FormatterInterface.php index 81b914972..349f8b6ad 100644 --- a/Creational/StaticFactory/FormatterInterface.php +++ b/Creational/StaticFactory/FormatterInterface.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Creational\StaticFactory; /** - * Class FormatterInterface + * Class FormatterInterface. */ interface FormatterInterface { diff --git a/Creational/StaticFactory/StaticFactory.php b/Creational/StaticFactory/StaticFactory.php index e4f2f962a..e4c4f4bce 100644 --- a/Creational/StaticFactory/StaticFactory.php +++ b/Creational/StaticFactory/StaticFactory.php @@ -4,23 +4,24 @@ /** * Note1: Remember, static => global => evil - * Note2: Cannot be subclassed or mock-upped or have multiple different instances + * Note2: Cannot be subclassed or mock-upped or have multiple different instances. */ class StaticFactory { /** - * the parametrized function to get create an instance + * the parametrized function to get create an instance. * * @param string $type * * @static * * @throws \InvalidArgumentException + * * @return FormatterInterface */ public static function factory($type) { - $className = __NAMESPACE__ . '\Format' . ucfirst($type); + $className = __NAMESPACE__.'\Format'.ucfirst($type); if (!class_exists($className)) { throw new \InvalidArgumentException('Missing format class.'); diff --git a/Creational/StaticFactory/Tests/StaticFactoryTest.php b/Creational/StaticFactory/Tests/StaticFactoryTest.php index f0304ca93..61f65af28 100644 --- a/Creational/StaticFactory/Tests/StaticFactoryTest.php +++ b/Creational/StaticFactory/Tests/StaticFactoryTest.php @@ -5,17 +5,15 @@ use DesignPatterns\Creational\StaticFactory\StaticFactory; /** - * Tests for Static Factory pattern - * + * Tests for Static Factory pattern. */ class StaticFactoryTest extends \PHPUnit_Framework_TestCase { - public function getTypeList() { return array( array('string'), - array('number') + array('number'), ); } @@ -33,6 +31,6 @@ public function testCreation($type) */ public function testException() { - StaticFactory::factory(""); + StaticFactory::factory(''); } } diff --git a/More/Delegation/JuniorDeveloper.php b/More/Delegation/JuniorDeveloper.php index 7506181ff..0946dad61 100644 --- a/More/Delegation/JuniorDeveloper.php +++ b/More/Delegation/JuniorDeveloper.php @@ -3,13 +3,12 @@ namespace DesignPatterns\More\Delegation; /** - * Class JuniorDeveloper - * @package DesignPatterns\Delegation + * Class JuniorDeveloper. */ class JuniorDeveloper { public function writeBadCode() { - return "Some junior developer generated code..."; + return 'Some junior developer generated code...'; } } diff --git a/More/Delegation/TeamLead.php b/More/Delegation/TeamLead.php index 315bd3b3c..9b7519065 100644 --- a/More/Delegation/TeamLead.php +++ b/More/Delegation/TeamLead.php @@ -3,9 +3,7 @@ namespace DesignPatterns\More\Delegation; /** - * Class TeamLead - * @package DesignPatterns\Delegation - * The `TeamLead` class, he delegate work to `JuniorDeveloper` + * Class TeamLead. */ class TeamLead { @@ -13,7 +11,8 @@ class TeamLead protected $slave; /** - * Give junior developer into teamlead submission + * Give junior developer into teamlead submission. + * * @param JuniorDeveloper $junior */ public function __construct(JuniorDeveloper $junior) @@ -22,7 +21,8 @@ public function __construct(JuniorDeveloper $junior) } /** - * TeamLead drink coffee, junior work + * TeamLead drink coffee, junior work. + * * @return mixed */ public function writeCode() diff --git a/More/Delegation/Tests/DelegationTest.php b/More/Delegation/Tests/DelegationTest.php index b19f871cd..7d0a33b49 100644 --- a/More/Delegation/Tests/DelegationTest.php +++ b/More/Delegation/Tests/DelegationTest.php @@ -5,7 +5,7 @@ use DesignPatterns\More\Delegation; /** - * DelegationTest tests the delegation pattern + * DelegationTest tests the delegation pattern. */ class DelegationTest extends \PHPUnit_Framework_TestCase { diff --git a/More/EAV/Attribute.php b/More/EAV/Attribute.php index 7a1a88ec7..3874360b3 100644 --- a/More/EAV/Attribute.php +++ b/More/EAV/Attribute.php @@ -5,7 +5,7 @@ use SplObjectStorage; /** - * Class Attribute + * Class Attribute. */ class Attribute implements ValueAccessInterface { @@ -34,6 +34,7 @@ public function getValues() /** * @param ValueInterface $value + * * @return $this */ public function addValue(ValueInterface $value) @@ -47,6 +48,7 @@ public function addValue(ValueInterface $value) /** * @param ValueInterface $value + * * @return $this */ public function removeValue(ValueInterface $value) @@ -68,6 +70,7 @@ public function getName() /** * @param string $name + * * @return $this */ public function setName($name) diff --git a/More/EAV/Entity.php b/More/EAV/Entity.php index e92444e53..ff26589f9 100644 --- a/More/EAV/Entity.php +++ b/More/EAV/Entity.php @@ -5,7 +5,7 @@ use SplObjectStorage; /** - * Class Entity + * Class Entity. */ class Entity implements ValueAccessInterface { @@ -34,6 +34,7 @@ public function getValues() /** * @param ValueInterface $value + * * @return $this */ public function addValue(ValueInterface $value) @@ -47,6 +48,7 @@ public function addValue(ValueInterface $value) /** * @param ValueInterface $value + * * @return $this */ public function removeValue(ValueInterface $value) @@ -68,6 +70,7 @@ public function getName() /** * @param string $name + * * @return $this */ public function setName($name) diff --git a/More/EAV/Tests/AttributeTest.php b/More/EAV/Tests/AttributeTest.php index 7e7efec1f..4affe41dc 100644 --- a/More/EAV/Tests/AttributeTest.php +++ b/More/EAV/Tests/AttributeTest.php @@ -6,7 +6,7 @@ use DesignPatterns\More\EAV\Value; /** - * AttributeTest tests the Attribute model of EAV pattern + * AttributeTest tests the Attribute model of EAV pattern. */ class AttributeTest extends \PHPUnit_Framework_TestCase { diff --git a/More/EAV/Tests/EntityTest.php b/More/EAV/Tests/EntityTest.php index 42c10f36f..ecd6c4031 100644 --- a/More/EAV/Tests/EntityTest.php +++ b/More/EAV/Tests/EntityTest.php @@ -2,19 +2,19 @@ namespace DesignPatterns\More\EAV\Tests; -use DesignPatterns\More\EAV\Entity; use DesignPatterns\More\EAV\Attribute; +use DesignPatterns\More\EAV\Entity; use DesignPatterns\More\EAV\Value; /** - * EntityTest tests the Entity model of EAV pattern + * EntityTest tests the Entity model of EAV pattern. */ class EntityTest extends \PHPUnit_Framework_TestCase { /** * @dataProvider valueProvider * - * @var string $name + * @var string */ public function testSetGetName($name) { @@ -27,7 +27,7 @@ public function testSetGetName($name) /** * @dataProvider valueProvider * - * @var string $name + * @var string * @var Value[] $values */ public function testAddValue($name, array $values) @@ -47,7 +47,7 @@ public function testAddValue($name, array $values) * @depends testAddValue * @dataProvider valueProvider * - * @var string $name + * @var string * @var Value[] $values */ public function testRemoveValue($name, array $values) diff --git a/More/EAV/Tests/ValueTest.php b/More/EAV/Tests/ValueTest.php index 1b9652127..f80f070f9 100644 --- a/More/EAV/Tests/ValueTest.php +++ b/More/EAV/Tests/ValueTest.php @@ -6,7 +6,7 @@ use DesignPatterns\More\EAV\Value; /** - * ValueTest tests the Value model of EAV pattern + * ValueTest tests the Value model of EAV pattern. */ class ValueTest extends \PHPUnit_Framework_TestCase { diff --git a/More/EAV/Value.php b/More/EAV/Value.php index 127f8ce85..2c156a948 100644 --- a/More/EAV/Value.php +++ b/More/EAV/Value.php @@ -3,7 +3,7 @@ namespace DesignPatterns\More\EAV; /** - * Class Value + * Class Value. */ class Value implements ValueInterface { @@ -28,6 +28,7 @@ public function __construct(Attribute $attribute) /** * @param Attribute $attribute + * * @return $this */ public function setAttribute(Attribute $attribute) @@ -57,6 +58,7 @@ public function getName() /** * @param string $name + * * @return $this */ public function setName($name) diff --git a/More/EAV/ValueAccessInterface.php b/More/EAV/ValueAccessInterface.php index 27820a80f..dde67b24c 100644 --- a/More/EAV/ValueAccessInterface.php +++ b/More/EAV/ValueAccessInterface.php @@ -3,7 +3,7 @@ namespace DesignPatterns\More\EAV; /** - * Interface ValueAccessInterface + * Interface ValueAccessInterface. */ interface ValueAccessInterface { diff --git a/More/EAV/ValueInterface.php b/More/EAV/ValueInterface.php index c0418352c..3737f6712 100644 --- a/More/EAV/ValueInterface.php +++ b/More/EAV/ValueInterface.php @@ -3,7 +3,7 @@ namespace DesignPatterns\More\EAV; /** - * Interface ValueInterface + * Interface ValueInterface. */ interface ValueInterface { diff --git a/More/EAV/example.php b/More/EAV/example.php index c5bb5c458..32ba5de1e 100644 --- a/More/EAV/example.php +++ b/More/EAV/example.php @@ -2,31 +2,31 @@ require '../../vendor/autoload.php'; -use DesignPatterns\More\EAV\Entity; use DesignPatterns\More\EAV\Attribute; +use DesignPatterns\More\EAV\Entity; use DesignPatterns\More\EAV\Value; // Create color attribute $color = (new Attribute())->setName('Color'); // Create color values -$colorSilver = (new Value($color))->setName('Silver'); -$colorGold = (new Value($color))->setName('Gold'); +$colorSilver = (new Value($color))->setName('Silver'); +$colorGold = (new Value($color))->setName('Gold'); $colorSpaceGrey = (new Value($color))->setName('Space Grey'); // Create memory attribute -$memory = (new Attribute())->setName('Memory'); +$memory = (new Attribute())->setName('Memory'); // Create memory values -$memory4Gb = (new Value($memory))->setName('4GB'); -$memory8Gb = (new Value($memory))->setName('8GB'); +$memory4Gb = (new Value($memory))->setName('4GB'); +$memory8Gb = (new Value($memory))->setName('8GB'); $memory16Gb = (new Value($memory))->setName('16GB'); // Create storage attribute -$storage = (new Attribute())->setName('Storage'); +$storage = (new Attribute())->setName('Storage'); // Create storage values -$storage128Gb = (new Value($storage))->setName('128GB'); -$storage256Gb = (new Value($storage))->setName('256GB'); -$storage512Gb = (new Value($storage))->setName('512GB'); -$storage1Tb = (new Value($storage))->setName('1TB'); +$storage128Gb = (new Value($storage))->setName('128GB'); +$storage256Gb = (new Value($storage))->setName('256GB'); +$storage512Gb = (new Value($storage))->setName('512GB'); +$storage1Tb = (new Value($storage))->setName('1TB'); // Create entities with specific values $mac = (new Entity()) @@ -39,8 +39,7 @@ ->addValue($memory8Gb) // storages ->addValue($storage256Gb) - ->addValue($storage512Gb) -; + ->addValue($storage512Gb); $macAir = (new Entity()) ->setName('MacBook Air') @@ -52,8 +51,7 @@ // storages ->addValue($storage128Gb) ->addValue($storage256Gb) - ->addValue($storage512Gb) -; + ->addValue($storage512Gb); $macPro = (new Entity()) ->setName('MacBook Pro') @@ -66,5 +64,4 @@ ->addValue($storage128Gb) ->addValue($storage256Gb) ->addValue($storage512Gb) - ->addValue($storage1Tb) -; + ->addValue($storage1Tb); diff --git a/More/Repository/MemoryStorage.php b/More/Repository/MemoryStorage.php index 1da09bc71..44276d552 100644 --- a/More/Repository/MemoryStorage.php +++ b/More/Repository/MemoryStorage.php @@ -2,15 +2,11 @@ namespace DesignPatterns\More\Repository; -use DesignPatterns\More\Repository\Storage; - /** - * Class MemoryStorage - * @package DesignPatterns\Repository + * Class MemoryStorage. */ class MemoryStorage implements Storage { - private $data; private $lastId; @@ -26,6 +22,7 @@ public function __construct() public function persist($data) { $this->data[++$this->lastId] = $data; + return $this->lastId; } diff --git a/More/Repository/Post.php b/More/Repository/Post.php index 9435d2e93..e9990b44c 100644 --- a/More/Repository/Post.php +++ b/More/Repository/Post.php @@ -3,10 +3,9 @@ namespace DesignPatterns\More\Repository; /** - * Post represents entity for some post that user left on the site + * Post represents entity for some post that user left on the site. * * Class Post - * @package DesignPatterns\Repository */ class Post { diff --git a/More/Repository/PostRepository.php b/More/Repository/PostRepository.php index 8b0ddac3e..e7687f3ca 100644 --- a/More/Repository/PostRepository.php +++ b/More/Repository/PostRepository.php @@ -2,11 +2,9 @@ namespace DesignPatterns\More\Repository; -use DesignPatterns\More\Repository\Storage; - /** * Repository for class Post - * This class is between Entity layer(class Post) and access object layer(interface Storage) + * This class is between Entity layer(class Post) and access object layer(interface Storage). * * Repository encapsulates the set of objects persisted in a data store and the operations performed over them * providing a more object-oriented view of the persistence layer @@ -15,7 +13,6 @@ * between the domain and data mapping layers * * Class PostRepository - * @package DesignPatterns\Repository */ class PostRepository { @@ -27,16 +24,17 @@ public function __construct(Storage $persistence) } /** - * Returns Post object by specified id + * Returns Post object by specified id. * * @param int $id + * * @return Post|null */ public function getById($id) { $arrayData = $this->persistence->retrieve($id); if (is_null($arrayData)) { - return null; + return; } $post = new Post(); @@ -50,9 +48,10 @@ public function getById($id) } /** - * Save post object and populate it with id + * Save post object and populate it with id. * * @param Post $post + * * @return Post */ public function save(Post $post) @@ -61,17 +60,19 @@ public function save(Post $post) 'author' => $post->getAuthor(), 'created' => $post->getCreated(), 'text' => $post->getText(), - 'title' => $post->getTitle() + 'title' => $post->getTitle(), )); $post->setId($id); + return $post; } /** - * Deletes specified Post object + * Deletes specified Post object. * * @param Post $post + * * @return bool */ public function delete(Post $post) diff --git a/More/Repository/Storage.php b/More/Repository/Storage.php index 4d528b470..a730f09a3 100644 --- a/More/Repository/Storage.php +++ b/More/Repository/Storage.php @@ -3,38 +3,39 @@ namespace DesignPatterns\More\Repository; /** - * Interface Storage + * Interface Storage. * * This interface describes methods for accessing storage. * Concrete realization could be whatever we want - in memory, relational database, NoSQL database and etc - * - * @package DesignPatterns\Repository */ interface Storage { /** * Method to persist data - * Returns new id for just persisted data + * Returns new id for just persisted data. * * @param array() $data + * * @return int */ public function persist($data); /** * Returns data by specified id. - * If there is no such data null is returned + * If there is no such data null is returned. * * @param int $id + * * @return array|null */ public function retrieve($id); /** * Delete data specified by id - * If there is no such data - false returns, if data has been successfully deleted - true returns + * If there is no such data - false returns, if data has been successfully deleted - true returns. * * @param int $id + * * @return bool */ public function delete($id); diff --git a/More/ServiceLocator/ServiceLocator.php b/More/ServiceLocator/ServiceLocator.php index 6699eca2a..b6314797f 100644 --- a/More/ServiceLocator/ServiceLocator.php +++ b/More/ServiceLocator/ServiceLocator.php @@ -27,21 +27,21 @@ class ServiceLocator implements ServiceLocatorInterface public function __construct() { - $this->services = array(); + $this->services = array(); $this->instantiated = array(); - $this->shared = array(); + $this->shared = array(); } /** * Registers a service with specific interface. * - * @param string $interface + * @param string $interface * @param string|object $service - * @param bool $share + * @param bool $share */ public function add($interface, $service, $share = true) { - /** + /* * When you add a service, you should register it * with its interface or with a string that you can use * in the future even if you will change the service implementation. @@ -51,7 +51,7 @@ public function add($interface, $service, $share = true) $this->instantiated[$interface] = $service; } $this->services[$interface] = (is_object($service) ? get_class($service) : $service); - $this->shared[$interface] = $share; + $this->shared[$interface] = $share; } /** @@ -63,7 +63,7 @@ public function add($interface, $service, $share = true) */ public function has($interface) { - return (isset($this->services[$interface]) || isset($this->instantiated[$interface])); + return isset($this->services[$interface]) || isset($this->instantiated[$interface]); } /** @@ -101,6 +101,7 @@ public function get($interface) if ($this->shared[$interface]) { $this->instantiated[$interface] = $object; } + return $object; } } diff --git a/More/ServiceLocator/Tests/ServiceLocatorTest.php b/More/ServiceLocator/Tests/ServiceLocatorTest.php index d6b7ef684..72f8607ac 100644 --- a/More/ServiceLocator/Tests/ServiceLocatorTest.php +++ b/More/ServiceLocator/Tests/ServiceLocatorTest.php @@ -5,7 +5,7 @@ use DesignPatterns\More\ServiceLocator\DatabaseService; use DesignPatterns\More\ServiceLocator\LogService; use DesignPatterns\More\ServiceLocator\ServiceLocator; -use \PHPUnit_Framework_TestCase as TestCase; +use PHPUnit_Framework_TestCase as TestCase; class ServiceLocatorTest extends TestCase { @@ -26,8 +26,8 @@ class ServiceLocatorTest extends TestCase public function setUp() { - $this->serviceLocator = new ServiceLocator(); - $this->logService = new LogService(); + $this->serviceLocator = new ServiceLocator(); + $this->logService = new LogService(); $this->databaseService = new DatabaseService(); } diff --git a/Structural/Adapter/Book.php b/Structural/Adapter/Book.php index ae3c6dc4f..6458beb03 100644 --- a/Structural/Adapter/Book.php +++ b/Structural/Adapter/Book.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\Adapter; /** - * Book is a concrete and standard paper book + * Book is a concrete and standard paper book. */ class Book implements PaperBookInterface { diff --git a/Structural/Adapter/EBookAdapter.php b/Structural/Adapter/EBookAdapter.php index a6c647635..3e4564a63 100644 --- a/Structural/Adapter/EBookAdapter.php +++ b/Structural/Adapter/EBookAdapter.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\Adapter; /** - * EBookAdapter is an adapter to fit an e-book like a paper book + * EBookAdapter is an adapter to fit an e-book like a paper book. * * This is the adapter here. Notice it implements PaperBookInterface, * therefore you don't have to change the code of the client which using paper book. @@ -16,7 +16,7 @@ class EBookAdapter implements PaperBookInterface protected $eBook; /** - * Notice the constructor, it "wraps" an electronic book + * Notice the constructor, it "wraps" an electronic book. * * @param EBookInterface $ebook */ @@ -26,7 +26,7 @@ public function __construct(EBookInterface $ebook) } /** - * This class makes the proper translation from one interface to another + * This class makes the proper translation from one interface to another. */ public function open() { @@ -34,7 +34,7 @@ public function open() } /** - * turns pages + * turns pages. */ public function turnPage() { diff --git a/Structural/Adapter/EBookInterface.php b/Structural/Adapter/EBookInterface.php index 15e022264..bd3dc26f3 100644 --- a/Structural/Adapter/EBookInterface.php +++ b/Structural/Adapter/EBookInterface.php @@ -3,19 +3,19 @@ namespace DesignPatterns\Structural\Adapter; /** - * EBookInterface is a contract for an electronic book + * EBookInterface is a contract for an electronic book. */ interface EBookInterface { /** - * go to next page + * go to next page. * * @return mixed */ public function pressNext(); /** - * start the book + * start the book. * * @return mixed */ diff --git a/Structural/Adapter/Kindle.php b/Structural/Adapter/Kindle.php index 14dc485de..06d448923 100644 --- a/Structural/Adapter/Kindle.php +++ b/Structural/Adapter/Kindle.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\Adapter; /** - * Kindle is a concrete electronic book + * Kindle is a concrete electronic book. */ class Kindle implements EBookInterface { diff --git a/Structural/Adapter/PaperBookInterface.php b/Structural/Adapter/PaperBookInterface.php index 12f310362..4b6214936 100644 --- a/Structural/Adapter/PaperBookInterface.php +++ b/Structural/Adapter/PaperBookInterface.php @@ -3,19 +3,19 @@ namespace DesignPatterns\Structural\Adapter; /** - * PaperBookInterface is a contract for a book + * PaperBookInterface is a contract for a book. */ interface PaperBookInterface { /** - * method to turn pages + * method to turn pages. * * @return mixed */ public function turnPage(); /** - * method to open the book + * method to open the book. * * @return mixed */ diff --git a/Structural/Adapter/Tests/AdapterTest.php b/Structural/Adapter/Tests/AdapterTest.php index ecbc9e29d..fd7713b24 100644 --- a/Structural/Adapter/Tests/AdapterTest.php +++ b/Structural/Adapter/Tests/AdapterTest.php @@ -2,14 +2,14 @@ namespace DesignPatterns\Structural\Adapter\Tests; +use DesignPatterns\Structural\Adapter\Book; use DesignPatterns\Structural\Adapter\EBookAdapter; use DesignPatterns\Structural\Adapter\Kindle; use DesignPatterns\Structural\Adapter\PaperBookInterface; -use DesignPatterns\Structural\Adapter\Book; /** * AdapterTest shows the use of an adapted e-book that behave like a book - * You don't have to change the code of your client + * You don't have to change the code of your client. */ class AdapterTest extends \PHPUnit_Framework_TestCase { @@ -21,13 +21,13 @@ public function getBook() return array( array(new Book()), // we build a "wrapped" electronic book in the adapter - array(new EBookAdapter(new Kindle())) + array(new EBookAdapter(new Kindle())), ); } /** * This client only knows paper book but surprise, surprise, the second book - * is in fact an electronic book, but both work the same way + * is in fact an electronic book, but both work the same way. * * @param PaperBookInterface $book * diff --git a/Structural/Bridge/Assemble.php b/Structural/Bridge/Assemble.php index 2b60889be..9b9d1149a 100644 --- a/Structural/Bridge/Assemble.php +++ b/Structural/Bridge/Assemble.php @@ -4,9 +4,8 @@ class Assemble implements Workshop { - public function work() { - print 'Assembled'; + echo 'Assembled'; } } diff --git a/Structural/Bridge/Car.php b/Structural/Bridge/Car.php index 27541991f..89be43142 100644 --- a/Structural/Bridge/Car.php +++ b/Structural/Bridge/Car.php @@ -3,11 +3,10 @@ namespace DesignPatterns\Structural\Bridge; /** - * Refined Abstraction + * Refined Abstraction. */ class Car extends Vehicle { - public function __construct(Workshop $workShop1, Workshop $workShop2) { parent::__construct($workShop1, $workShop2); @@ -15,7 +14,7 @@ public function __construct(Workshop $workShop1, Workshop $workShop2) public function manufacture() { - print 'Car '; + echo 'Car '; $this->workShop1->work(); $this->workShop2->work(); } diff --git a/Structural/Bridge/Motorcycle.php b/Structural/Bridge/Motorcycle.php index b021ce619..f008785fc 100644 --- a/Structural/Bridge/Motorcycle.php +++ b/Structural/Bridge/Motorcycle.php @@ -3,11 +3,10 @@ namespace DesignPatterns\Structural\Bridge; /** - * Refined Abstraction + * Refined Abstraction. */ class Motorcycle extends Vehicle { - public function __construct(Workshop $workShop1, Workshop $workShop2) { parent::__construct($workShop1, $workShop2); @@ -15,7 +14,7 @@ public function __construct(Workshop $workShop1, Workshop $workShop2) public function manufacture() { - print 'Motorcycle '; + echo 'Motorcycle '; $this->workShop1->work(); $this->workShop2->work(); } diff --git a/Structural/Bridge/Produce.php b/Structural/Bridge/Produce.php index b2b050572..a382f2d72 100644 --- a/Structural/Bridge/Produce.php +++ b/Structural/Bridge/Produce.php @@ -3,13 +3,12 @@ namespace DesignPatterns\Structural\Bridge; /** - * Concrete Implementation + * Concrete Implementation. */ class Produce implements Workshop { - public function work() { - print 'Produced '; + echo 'Produced '; } } diff --git a/Structural/Bridge/Tests/BridgeTest.php b/Structural/Bridge/Tests/BridgeTest.php index e07afe996..0a89a86ca 100644 --- a/Structural/Bridge/Tests/BridgeTest.php +++ b/Structural/Bridge/Tests/BridgeTest.php @@ -9,7 +9,6 @@ class BridgeTest extends \PHPUnit_Framework_TestCase { - public function testCar() { $vehicle = new Car(new Produce(), new Assemble()); diff --git a/Structural/Bridge/Vehicle.php b/Structural/Bridge/Vehicle.php index 10b0d0364..f519d70fa 100644 --- a/Structural/Bridge/Vehicle.php +++ b/Structural/Bridge/Vehicle.php @@ -3,11 +3,10 @@ namespace DesignPatterns\Structural\Bridge; /** - * Abstraction + * Abstraction. */ abstract class Vehicle { - protected $workShop1; protected $workShop2; diff --git a/Structural/Bridge/Workshop.php b/Structural/Bridge/Workshop.php index dc6288607..9cb26c599 100644 --- a/Structural/Bridge/Workshop.php +++ b/Structural/Bridge/Workshop.php @@ -3,10 +3,9 @@ namespace DesignPatterns\Structural\Bridge; /** - * Implementer + * Implementer. */ interface Workshop { - public function work(); } diff --git a/Structural/Composite/Form.php b/Structural/Composite/Form.php index fbf3b50c9..42f1bc13c 100644 --- a/Structural/Composite/Form.php +++ b/Structural/Composite/Form.php @@ -15,7 +15,7 @@ class Form extends FormElement /** * runs through all elements and calls render() on them, then returns the complete representation - * of the form + * of the form. * * from the outside, one will not see this and the form will act like a single object instance * @@ -28,7 +28,7 @@ public function render($indent = 0) $formCode = ''; foreach ($this->elements as $element) { - $formCode .= $element->render($indent + 1) . PHP_EOL; + $formCode .= $element->render($indent + 1).PHP_EOL; } return $formCode; diff --git a/Structural/Composite/FormElement.php b/Structural/Composite/FormElement.php index 8063c89e5..0055aeea7 100644 --- a/Structural/Composite/FormElement.php +++ b/Structural/Composite/FormElement.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Structural\Composite; /** - * Class FormElement + * Class FormElement. */ abstract class FormElement { /** - * renders the elements' code + * renders the elements' code. * * @param int $indent * diff --git a/Structural/Composite/InputElement.php b/Structural/Composite/InputElement.php index 30d861522..19786d517 100644 --- a/Structural/Composite/InputElement.php +++ b/Structural/Composite/InputElement.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Structural\Composite; /** - * Class InputElement + * Class InputElement. */ class InputElement extends FormElement { /** - * renders the input element HTML + * renders the input element HTML. * * @param int $indent * @@ -16,6 +16,6 @@ class InputElement extends FormElement */ public function render($indent = 0) { - return str_repeat(' ', $indent) . ''; + return str_repeat(' ', $indent).''; } } diff --git a/Structural/Composite/Tests/CompositeTest.php b/Structural/Composite/Tests/CompositeTest.php index f3ee1d13c..510a06b05 100644 --- a/Structural/Composite/Tests/CompositeTest.php +++ b/Structural/Composite/Tests/CompositeTest.php @@ -5,11 +5,10 @@ use DesignPatterns\Structural\Composite; /** - * FormTest tests the composite pattern on Form + * FormTest tests the composite pattern on Form. */ class CompositeTest extends \PHPUnit_Framework_TestCase { - public function testRender() { $form = new Composite\Form(); @@ -25,7 +24,7 @@ public function testRender() /** * The all point of this pattern, a Composite must inherit from the node - * if you want to builld trees + * if you want to builld trees. */ public function testFormImplementsFormEelement() { diff --git a/Structural/Composite/TextElement.php b/Structural/Composite/TextElement.php index ed50294c3..48b33bab1 100644 --- a/Structural/Composite/TextElement.php +++ b/Structural/Composite/TextElement.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Structural\Composite; /** - * Class TextElement + * Class TextElement. */ class TextElement extends FormElement { /** - * renders the text element + * renders the text element. * * @param int $indent * @@ -16,6 +16,6 @@ class TextElement extends FormElement */ public function render($indent = 0) { - return str_repeat(' ', $indent) . 'this is a text element'; + return str_repeat(' ', $indent).'this is a text element'; } } diff --git a/Structural/DataMapper/Tests/DataMapperTest.php b/Structural/DataMapper/Tests/DataMapperTest.php index fb531e963..551c11e3e 100644 --- a/Structural/DataMapper/Tests/DataMapperTest.php +++ b/Structural/DataMapper/Tests/DataMapperTest.php @@ -2,11 +2,11 @@ namespace DesignPatterns\Structural\DataMapper\Tests; -use DesignPatterns\Structural\DataMapper\UserMapper; use DesignPatterns\Structural\DataMapper\User; +use DesignPatterns\Structural\DataMapper\UserMapper; /** - * UserMapperTest tests the datamapper pattern + * UserMapperTest tests the datamapper pattern. */ class DataMapperTest extends \PHPUnit_Framework_TestCase { @@ -66,9 +66,9 @@ public function testPersistExisting(User $user) public function testRestoreOne(User $existing) { $row = array( - 'userid' => 1, + 'userid' => 1, 'username' => 'Odysseus', - 'email' => 'Odysseus@ithaca.gr' + 'email' => 'Odysseus@ithaca.gr', ); $rows = new \ArrayIterator(array($row)); $this->dbal->expects($this->once()) diff --git a/Structural/DataMapper/User.php b/Structural/DataMapper/User.php index 78e60a824..8d8d2b270 100644 --- a/Structural/DataMapper/User.php +++ b/Structural/DataMapper/User.php @@ -3,12 +3,11 @@ namespace DesignPatterns\Structural\DataMapper; /** - * DataMapper pattern + * DataMapper pattern. * * This is our representation of a DataBase record in the memory (Entity) * * Validation would also go in this object - * */ class User { diff --git a/Structural/DataMapper/UserMapper.php b/Structural/DataMapper/UserMapper.php index 0ee535220..f147063fe 100644 --- a/Structural/DataMapper/UserMapper.php +++ b/Structural/DataMapper/UserMapper.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\DataMapper; /** - * class UserMapper + * class UserMapper. */ class UserMapper { @@ -21,19 +21,19 @@ public function __construct(DBAL $dbLayer) } /** - * saves a user object from memory to Database + * saves a user object from memory to Database. * * @param User $user * - * @return boolean + * @return bool */ public function save(User $user) { /* $data keys should correspond to valid Table columns on the Database */ $data = array( - 'userid' => $user->getUserId(), + 'userid' => $user->getUserId(), 'username' => $user->getUsername(), - 'email' => $user->getEmail(), + 'email' => $user->getEmail(), ); /* if no ID specified create new user else update the one in the Database */ @@ -51,11 +51,12 @@ public function save(User $user) /** * finds a user from Database based on ID and returns a User object located - * in memory + * in memory. * * @param int $id * * @throws \InvalidArgumentException + * * @return User */ public function findById($id) @@ -72,14 +73,14 @@ public function findById($id) /** * fetches an array from Database and returns an array of User objects - * located in memory + * located in memory. * * @return array */ public function findAll() { $resultSet = $this->adapter->findAll(); - $entries = array(); + $entries = array(); foreach ($resultSet as $row) { $entries[] = $this->mapObject($row); @@ -89,7 +90,7 @@ public function findAll() } /** - * Maps a table row to an object + * Maps a table row to an object. * * @param array $row * diff --git a/Structural/Decorator/Decorator.php b/Structural/Decorator/Decorator.php index 182c07a60..0b8fde395 100644 --- a/Structural/Decorator/Decorator.php +++ b/Structural/Decorator/Decorator.php @@ -9,7 +9,7 @@ */ /** - * class Decorator + * class Decorator. */ abstract class Decorator implements RendererInterface { diff --git a/Structural/Decorator/RenderInJson.php b/Structural/Decorator/RenderInJson.php index ebcc577c9..71943bd7e 100644 --- a/Structural/Decorator/RenderInJson.php +++ b/Structural/Decorator/RenderInJson.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Structural\Decorator; /** - * Class RenderInJson + * Class RenderInJson. */ class RenderInJson extends Decorator { /** - * render data as JSON + * render data as JSON. * * @return mixed|string */ diff --git a/Structural/Decorator/RenderInXml.php b/Structural/Decorator/RenderInXml.php index f8e92a06c..2eab7ca15 100644 --- a/Structural/Decorator/RenderInXml.php +++ b/Structural/Decorator/RenderInXml.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Structural\Decorator; /** - * Class RenderInXml + * Class RenderInXml. */ class RenderInXml extends Decorator { /** - * render data as XML + * render data as XML. * * @return mixed|string */ diff --git a/Structural/Decorator/RendererInterface.php b/Structural/Decorator/RendererInterface.php index 295797076..92b00eff5 100644 --- a/Structural/Decorator/RendererInterface.php +++ b/Structural/Decorator/RendererInterface.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Structural\Decorator; /** - * Class RendererInterface + * Class RendererInterface. */ interface RendererInterface { /** - * render data + * render data. * * @return mixed */ diff --git a/Structural/Decorator/Tests/DecoratorTest.php b/Structural/Decorator/Tests/DecoratorTest.php index c50181f8d..689caf26e 100644 --- a/Structural/Decorator/Tests/DecoratorTest.php +++ b/Structural/Decorator/Tests/DecoratorTest.php @@ -5,11 +5,10 @@ use DesignPatterns\Structural\Decorator; /** - * DecoratorTest tests the decorator pattern + * DecoratorTest tests the decorator pattern. */ class DecoratorTest extends \PHPUnit_Framework_TestCase { - protected $service; protected function setUp() @@ -35,7 +34,7 @@ public function testXmlDecorator() } /** - * The first key-point of this pattern : + * The first key-point of this pattern :. */ public function testDecoratorMustImplementsRenderer() { @@ -45,7 +44,7 @@ public function testDecoratorMustImplementsRenderer() } /** - * Second key-point of this pattern : the decorator is type-hinted + * Second key-point of this pattern : the decorator is type-hinted. * * @expectedException \PHPUnit_Framework_Error */ @@ -59,7 +58,7 @@ public function testDecoratorTypeHinted() } /** - * Second key-point of this pattern : the decorator is type-hinted + * Second key-point of this pattern : the decorator is type-hinted. * * @requires PHP 7 * @expectedException TypeError @@ -70,7 +69,7 @@ public function testDecoratorTypeHintedForPhp7() } /** - * The decorator implements and wraps the same interface + * The decorator implements and wraps the same interface. */ public function testDecoratorOnlyAcceptRenderer() { diff --git a/Structural/Decorator/Webservice.php b/Structural/Decorator/Webservice.php index e6bf30690..e2bcc6940 100644 --- a/Structural/Decorator/Webservice.php +++ b/Structural/Decorator/Webservice.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\Decorator; /** - * Class Webservice + * Class Webservice. */ class Webservice implements RendererInterface { diff --git a/Structural/DependencyInjection/AbstractConfig.php b/Structural/DependencyInjection/AbstractConfig.php index 85e52454a..f2da4dc33 100644 --- a/Structural/DependencyInjection/AbstractConfig.php +++ b/Structural/DependencyInjection/AbstractConfig.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\DependencyInjection; /** - * class AbstractConfig + * class AbstractConfig. */ abstract class AbstractConfig { diff --git a/Structural/DependencyInjection/ArrayConfig.php b/Structural/DependencyInjection/ArrayConfig.php index 91bca3366..f26c089ea 100644 --- a/Structural/DependencyInjection/ArrayConfig.php +++ b/Structural/DependencyInjection/ArrayConfig.php @@ -3,17 +3,18 @@ namespace DesignPatterns\Structural\DependencyInjection; /** - * class ArrayConfig + * class ArrayConfig. * * uses array as data source */ class ArrayConfig extends AbstractConfig implements Parameters { /** - * Get parameter + * Get parameter. * * @param string|int $key - * @param null $default + * @param null $default + * * @return mixed */ public function get($key, $default = null) @@ -21,14 +22,15 @@ public function get($key, $default = null) if (isset($this->storage[$key])) { return $this->storage[$key]; } + return $default; } /** - * Set parameter + * Set parameter. * * @param string|int $key - * @param mixed $value + * @param mixed $value */ public function set($key, $value) { diff --git a/Structural/DependencyInjection/Connection.php b/Structural/DependencyInjection/Connection.php index 9e131c2da..d38908969 100644 --- a/Structural/DependencyInjection/Connection.php +++ b/Structural/DependencyInjection/Connection.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\DependencyInjection; /** - * Class Connection + * Class Connection. */ class Connection { @@ -26,7 +26,7 @@ public function __construct(Parameters $config) } /** - * connection using the injected config + * connection using the injected config. */ public function connect() { @@ -42,6 +42,7 @@ public function connect() * * @return string */ + public function getHost() { return $this->host; diff --git a/Structural/DependencyInjection/Parameters.php b/Structural/DependencyInjection/Parameters.php index dabe895a2..c49f4c7a6 100644 --- a/Structural/DependencyInjection/Parameters.php +++ b/Structural/DependencyInjection/Parameters.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Structural\DependencyInjection; /** - * Parameters interface + * Parameters interface. */ interface Parameters { /** - * Get parameter + * Get parameter. * * @param string|int $key * @@ -17,7 +17,7 @@ interface Parameters public function get($key); /** - * Set parameter + * Set parameter. * * @param string|int $key * @param mixed $value diff --git a/Structural/Facade/BiosInterface.php b/Structural/Facade/BiosInterface.php index 869dcd981..823af041c 100644 --- a/Structural/Facade/BiosInterface.php +++ b/Structural/Facade/BiosInterface.php @@ -3,29 +3,29 @@ namespace DesignPatterns\Structural\Facade; /** - * Class BiosInterface + * Class BiosInterface. */ interface BiosInterface { /** - * execute the BIOS + * execute the BIOS. */ public function execute(); /** - * wait for halt + * wait for halt. */ public function waitForKeyPress(); /** - * launches the OS + * launches the OS. * * @param OsInterface $os */ public function launch(OsInterface $os); /** - * power down BIOS + * power down BIOS. */ public function powerDown(); } diff --git a/Structural/Facade/Facade.php b/Structural/Facade/Facade.php index c0048b4dc..50c665da4 100644 --- a/Structural/Facade/Facade.php +++ b/Structural/Facade/Facade.php @@ -3,7 +3,6 @@ namespace DesignPatterns\Structural\Facade; /** - * * */ class Facade @@ -20,7 +19,7 @@ class Facade /** * This is the perfect time to use a dependency injection container - * to create an instance of this class + * to create an instance of this class. * * @param BiosInterface $bios * @param OsInterface $os @@ -32,7 +31,7 @@ public function __construct(BiosInterface $bios, OsInterface $os) } /** - * turn on the system + * turn on the system. */ public function turnOn() { @@ -42,7 +41,7 @@ public function turnOn() } /** - * turn off the system + * turn off the system. */ public function turnOff() { diff --git a/Structural/Facade/OsInterface.php b/Structural/Facade/OsInterface.php index 3b09eb180..8394fd4ac 100644 --- a/Structural/Facade/OsInterface.php +++ b/Structural/Facade/OsInterface.php @@ -3,12 +3,12 @@ namespace DesignPatterns\Structural\Facade; /** - * Class OsInterface + * Class OsInterface. */ interface OsInterface { /** - * halt the OS + * halt the OS. */ public function halt(); } diff --git a/Structural/Facade/Tests/FacadeTest.php b/Structural/Facade/Tests/FacadeTest.php index 18133e933..e6038a04c 100644 --- a/Structural/Facade/Tests/FacadeTest.php +++ b/Structural/Facade/Tests/FacadeTest.php @@ -6,11 +6,10 @@ use DesignPatterns\Structural\Facade\OsInterface; /** - * FacadeTest shows example of facades + * FacadeTest shows example of facades. */ class FacadeTest extends \PHPUnit_Framework_TestCase { - public function getComputer() { $bios = $this->getMockBuilder('DesignPatterns\Structural\Facade\BiosInterface') @@ -30,6 +29,7 @@ public function getComputer() ->will($this->returnValue('Linux')); $facade = new Computer($bios, $operatingSys); + return array(array($facade, $operatingSys)); } diff --git a/Structural/FluentInterface/Sql.php b/Structural/FluentInterface/Sql.php index 35af3efc0..58ba49130 100644 --- a/Structural/FluentInterface/Sql.php +++ b/Structural/FluentInterface/Sql.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\FluentInterface; /** - * class SQL + * class SQL. */ class Sql { @@ -23,7 +23,7 @@ class Sql protected $where = array(); /** - * adds select fields + * adds select fields. * * @param array $fields * @@ -37,7 +37,7 @@ public function select(array $fields = array()) } /** - * adds a FROM clause + * adds a FROM clause. * * @param string $table * @param string $alias @@ -46,13 +46,13 @@ public function select(array $fields = array()) */ public function from($table, $alias) { - $this->from[] = $table . ' AS ' . $alias; + $this->from[] = $table.' AS '.$alias; return $this; } /** - * adds a WHERE condition + * adds a WHERE condition. * * @param string $condition * @@ -67,14 +67,14 @@ public function where($condition) /** * Gets the query, just an example of building a query, - * no check on consistency + * no check on consistency. * * @return string */ public function getQuery() { - return 'SELECT ' . implode(',', $this->fields) - . ' FROM ' . implode(',', $this->from) - . ' WHERE ' . implode(' AND ', $this->where); + return 'SELECT '.implode(',', $this->fields) + .' FROM '.implode(',', $this->from) + .' WHERE '.implode(' AND ', $this->where); } } diff --git a/Structural/FluentInterface/Tests/FluentInterfaceTest.php b/Structural/FluentInterface/Tests/FluentInterfaceTest.php index 98ea99d3a..ae4e6561a 100644 --- a/Structural/FluentInterface/Tests/FluentInterfaceTest.php +++ b/Structural/FluentInterface/Tests/FluentInterfaceTest.php @@ -5,11 +5,10 @@ use DesignPatterns\Structural\FluentInterface\Sql; /** - * FluentInterfaceTest tests the fluent interface SQL + * FluentInterfaceTest tests the fluent interface SQL. */ class FluentInterfaceTest extends \PHPUnit_Framework_TestCase { - public function testBuildSQL() { $instance = new Sql(); diff --git a/Structural/Proxy/Record.php b/Structural/Proxy/Record.php index 38481aada..7ae4a3cfc 100644 --- a/Structural/Proxy/Record.php +++ b/Structural/Proxy/Record.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\Proxy; /** - * class Record + * class Record. */ class Record { @@ -21,7 +21,7 @@ public function __construct($data = null) } /** - * magic setter + * magic setter. * * @param string $name * @param mixed $value @@ -34,7 +34,7 @@ public function __set($name, $value) } /** - * magic getter + * magic getter. * * @param string $name * @@ -45,7 +45,7 @@ public function __get($name) if (array_key_exists($name, $this->data)) { return $this->data[(string) $name]; } else { - return null; + return; } } } diff --git a/Structural/Proxy/RecordProxy.php b/Structural/Proxy/RecordProxy.php index 1f68cffe8..f8c78a819 100644 --- a/Structural/Proxy/RecordProxy.php +++ b/Structural/Proxy/RecordProxy.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\Proxy; /** - * Class RecordProxy + * Class RecordProxy. */ class RecordProxy extends Record { @@ -35,7 +35,7 @@ public function __construct($data) } /** - * magic setter + * magic setter. * * @param string $name * @param mixed $value diff --git a/Structural/Registry/Registry.php b/Structural/Registry/Registry.php index d1c6b13e1..e40d0c336 100644 --- a/Structural/Registry/Registry.php +++ b/Structural/Registry/Registry.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\Registry; /** - * class Registry + * class Registry. */ abstract class Registry { @@ -15,12 +15,13 @@ abstract class Registry protected static $storedValues = array(); /** - * sets a value + * sets a value. * * @param string $key * @param mixed $value * * @static + * * @return void */ public static function set($key, $value) @@ -29,11 +30,12 @@ public static function set($key, $value) } /** - * gets a value from the registry + * gets a value from the registry. * * @param string $key * * @static + * * @return mixed */ public static function get($key) diff --git a/Structural/Registry/Tests/RegistryTest.php b/Structural/Registry/Tests/RegistryTest.php index 64685d4ff..e8899763f 100644 --- a/Structural/Registry/Tests/RegistryTest.php +++ b/Structural/Registry/Tests/RegistryTest.php @@ -6,7 +6,6 @@ class RegistryTest extends \PHPUnit_Framework_TestCase { - public function testSetAndGetLogger() { Registry::set(Registry::LOGGER, new \StdClass());