mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-06 14:04:55 +02:00
Merge pull request #130 from nueckman/codestyle-1
codestyle - remove trailing whitespaces
This commit is contained in:
commit
8eed6f9c21
@ -4,7 +4,7 @@ namespace DesignPatterns\Behavioral\Command;
|
||||
|
||||
/**
|
||||
* This concrete command calls "print" on the Receiver, but an external
|
||||
* invoker just know he can call "execute"
|
||||
* invoker just know he can call "execute"
|
||||
*/
|
||||
class HelloCommand implements CommandInterface
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ namespace DesignPatterns\Behavioral\NullObject;
|
||||
|
||||
/**
|
||||
* LoggerInterface is a contract for logging something
|
||||
*
|
||||
*
|
||||
* Key feature: NullLogger MUST inherit from this interface like any other Loggers
|
||||
*/
|
||||
interface LoggerInterface
|
||||
|
@ -5,7 +5,7 @@ namespace DesignPatterns\Behavioral\NullObject;
|
||||
/**
|
||||
* Performance concerns : ok there is a call for nothing but we spare an "if is_null"
|
||||
* I didn't run a benchmark but I think it's equivalent.
|
||||
*
|
||||
*
|
||||
* Key feature : of course this logger MUST implement the same interface (or abstract)
|
||||
* like the other loggers.
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@ namespace DesignPatterns\Behavioral\Observer;
|
||||
|
||||
/**
|
||||
* Observer pattern : The observed object (the subject)
|
||||
*
|
||||
*
|
||||
* The subject maintains a list of Observers and sends notifications.
|
||||
*
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@ class UserObserver implements \SplObserver
|
||||
/**
|
||||
* This is the only method to implement as an observer.
|
||||
* It is called by the Subject (usually by SplSubject::notify() )
|
||||
*
|
||||
*
|
||||
* @param \SplSubject $subject
|
||||
*/
|
||||
public function update(\SplSubject $subject)
|
||||
|
@ -12,7 +12,7 @@ class Either extends AbstractSpecification
|
||||
|
||||
/**
|
||||
* A composite wrapper of two specifications
|
||||
*
|
||||
*
|
||||
* @param SpecificationInterface $left
|
||||
* @param SpecificationInterface $right
|
||||
*/
|
||||
@ -24,9 +24,9 @@ class Either extends AbstractSpecification
|
||||
|
||||
/**
|
||||
* Returns the evaluation of both wrapped specifications as a logical OR
|
||||
*
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSatisfiedBy(Item $item)
|
||||
|
@ -10,7 +10,7 @@ class Item
|
||||
|
||||
/**
|
||||
* An item must have a price
|
||||
*
|
||||
*
|
||||
* @param int $price
|
||||
*/
|
||||
public function __construct($price)
|
||||
@ -20,7 +20,7 @@ class Item
|
||||
|
||||
/**
|
||||
* Get the items price
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPrice()
|
||||
|
@ -11,7 +11,7 @@ class Not extends AbstractSpecification
|
||||
|
||||
/**
|
||||
* Creates a new specification wrapping another
|
||||
*
|
||||
*
|
||||
* @param SpecificationInterface $spec
|
||||
*/
|
||||
public function __construct(SpecificationInterface $spec)
|
||||
@ -21,9 +21,9 @@ class Not extends AbstractSpecification
|
||||
|
||||
/**
|
||||
* Returns the negated result of the wrapped specification
|
||||
*
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSatisfiedBy(Item $item)
|
||||
|
@ -10,7 +10,7 @@ abstract class Journey
|
||||
/**
|
||||
* This is the public service provided by this class and its subclasses.
|
||||
* Notice it is final to "freeze" the global behavior of algorithm.
|
||||
* If you want to override this contract, make an interface with only takeATrip()
|
||||
* If you want to override this contract, make an interface with only takeATrip()
|
||||
* and subclass it.
|
||||
*/
|
||||
final public function takeATrip()
|
||||
|
@ -6,10 +6,10 @@ namespace DesignPatterns\Behavioral\Visitor;
|
||||
* Visitor Pattern
|
||||
*
|
||||
* The contract for the visitor.
|
||||
*
|
||||
*
|
||||
* Note 1 : in C++ or java, with method polymorphism based on type-hint, there are many
|
||||
* methods visit() with different type for the 'role' parameter.
|
||||
*
|
||||
*
|
||||
* Note 2 : the visitor must not choose itself which method to
|
||||
* invoke, it is the Visitee that make this decision.
|
||||
*/
|
||||
@ -17,14 +17,14 @@ interface RoleVisitorInterface
|
||||
{
|
||||
/**
|
||||
* Visit a User object
|
||||
*
|
||||
*
|
||||
* @param \DesignPatterns\Behavioral\Visitor\User $role
|
||||
*/
|
||||
public function visitUser(User $role);
|
||||
|
||||
/**
|
||||
* Visit a Group object
|
||||
*
|
||||
*
|
||||
* @param \DesignPatterns\Behavioral\Visitor\Group $role
|
||||
*/
|
||||
public function visitGroup(Group $role);
|
||||
|
@ -21,7 +21,7 @@ abstract class AbstractFactory
|
||||
{
|
||||
/**
|
||||
* Creates a text component
|
||||
*
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return Text
|
||||
@ -30,7 +30,7 @@ abstract class AbstractFactory
|
||||
|
||||
/**
|
||||
* Creates a picture component
|
||||
*
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $name
|
||||
*
|
||||
|
@ -21,9 +21,9 @@ class AbstractFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* This is the client of factories. Note that the client does not
|
||||
* care which factory is given to him, he can create any component he
|
||||
* care which factory is given to him, he can create any component he
|
||||
* wants and render how he wants.
|
||||
*
|
||||
*
|
||||
* @dataProvider getFactories
|
||||
*/
|
||||
public function testComponentCreation(AbstractFactory $factory)
|
||||
|
@ -17,7 +17,6 @@ class BikeBuilder implements BuilderInterface
|
||||
*/
|
||||
public function addDoors()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,8 +4,8 @@ namespace DesignPatterns\Creational\Builder;
|
||||
|
||||
/**
|
||||
* Director is part of the builder pattern. It knows the interface of the builder
|
||||
* and builds a complex object with the help of the builder.
|
||||
*
|
||||
* and builds a complex object with the help of the builder.
|
||||
*
|
||||
* You can also inject many builders instead of one to build more complex objects
|
||||
*/
|
||||
class Director
|
||||
|
@ -7,5 +7,4 @@ namespace DesignPatterns\Creational\Builder\Parts;
|
||||
*/
|
||||
class Bike extends Vehicle
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -7,5 +7,4 @@ namespace DesignPatterns\Creational\Builder\Parts;
|
||||
*/
|
||||
class Car extends Vehicle
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -7,5 +7,4 @@ namespace DesignPatterns\Creational\Builder\Parts;
|
||||
*/
|
||||
class Door
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -7,5 +7,4 @@ namespace DesignPatterns\Creational\Builder\Parts;
|
||||
*/
|
||||
class Engine
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -7,5 +7,4 @@ namespace DesignPatterns\Creational\Builder\Parts;
|
||||
*/
|
||||
class Wheel
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class DirectorTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* Here we test the build process. Notice that the client don't know
|
||||
* anything about the concrete builder.
|
||||
*
|
||||
*
|
||||
* @dataProvider getBuilder
|
||||
*/
|
||||
public function testBuild(BuilderInterface $builder)
|
||||
|
@ -13,20 +13,20 @@ abstract class FactoryMethod
|
||||
|
||||
/**
|
||||
* The children of the class must implement this method
|
||||
*
|
||||
*
|
||||
* Sometimes this method can be public to get "raw" object
|
||||
*
|
||||
*
|
||||
* @param string $type a generic type
|
||||
*
|
||||
*
|
||||
* @return VehicleInterface a new vehicle
|
||||
*/
|
||||
abstract protected function createVehicle($type);
|
||||
|
||||
/**
|
||||
* Creates a new vehicle
|
||||
*
|
||||
*
|
||||
* @param int $type
|
||||
*
|
||||
*
|
||||
* @return VehicleInterface a new vehicle
|
||||
*/
|
||||
public function create($type)
|
||||
|
@ -26,6 +26,5 @@ class Porsche implements VehicleInterface
|
||||
*/
|
||||
public function addTuningAMG()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,13 +32,12 @@ class Multiton
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the instance with the given name, e.g. Multiton::INSTANCE_1
|
||||
* uses lazy initialization
|
||||
*
|
||||
*
|
||||
* @param string $instanceName
|
||||
*
|
||||
* @return Multiton
|
||||
@ -59,7 +58,6 @@ class Multiton
|
||||
*/
|
||||
private function __clone()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,6 +67,5 @@ class Multiton
|
||||
*/
|
||||
private function __wakeup()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\Creational\Pool\Tests;
|
||||
|
||||
|
@ -17,6 +17,5 @@ class BarBookPrototype extends BookPrototype
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,5 @@ class FooBookPrototype extends BookPrototype
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,5 @@ class Bicycle implements VehicleInterface
|
||||
*/
|
||||
public function driveTo($destination)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class ConcreteFactory
|
||||
|
||||
/**
|
||||
* Creates a vehicle
|
||||
*
|
||||
*
|
||||
* @param string $type a known type key
|
||||
*
|
||||
* @return VehicleInterface a new instance of VehicleInterface
|
||||
|
@ -12,6 +12,5 @@ class Scooter implements VehicleInterface
|
||||
*/
|
||||
public function driveTo($destination)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ class Singleton
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
|
||||
if (null === static::$instance) {
|
||||
static::$instance = new static;
|
||||
}
|
||||
@ -33,7 +32,6 @@ class Singleton
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -43,7 +41,6 @@ class Singleton
|
||||
*/
|
||||
private function __clone()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,6 +50,5 @@ class Singleton
|
||||
*/
|
||||
private function __wakeup()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,4 @@ namespace DesignPatterns\Creational\StaticFactory;
|
||||
*/
|
||||
class FormatNumber implements FormatterInterface
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -7,5 +7,4 @@ namespace DesignPatterns\Creational\StaticFactory;
|
||||
*/
|
||||
class FormatString implements FormatterInterface
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -7,5 +7,4 @@ namespace DesignPatterns\Creational\StaticFactory;
|
||||
*/
|
||||
interface FormatterInterface
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ namespace DesignPatterns\Repository;
|
||||
/**
|
||||
* Repository for class Post
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* Repository also supports the objective of achieving a clean separation and one-way dependency
|
||||
* between the domain and data mapping layers
|
||||
*
|
||||
|
@ -12,7 +12,6 @@ class Book implements PaperBookInterface
|
||||
*/
|
||||
public function open()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -20,6 +19,5 @@ class Book implements PaperBookInterface
|
||||
*/
|
||||
public function turnPage()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace DesignPatterns\Structural\Adapter;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
@ -12,7 +12,6 @@ class Kindle implements EBookInterface
|
||||
*/
|
||||
public function pressNext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -20,6 +19,5 @@ class Kindle implements EBookInterface
|
||||
*/
|
||||
public function pressStart()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ abstract class Decorator implements RendererInterface
|
||||
/**
|
||||
* You must type-hint the wrapped component :
|
||||
* It ensures you can call renderData() in the subclasses !
|
||||
*
|
||||
*
|
||||
* @param RendererInterface $wrappable
|
||||
*/
|
||||
public function __construct(RendererInterface $wrappable)
|
||||
|
@ -46,7 +46,7 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* Second key-point of this pattern : the decorator is type-hinted
|
||||
*
|
||||
*
|
||||
* @expectedException \PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testDecoratorTypeHinted()
|
||||
|
@ -4,7 +4,7 @@ namespace DesignPatterns\Structural\Facade;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Facade
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ class Sql
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the query, just an example of building a query,
|
||||
* Gets the query, just an example of building a query,
|
||||
* no check on consistency
|
||||
*
|
||||
* @return string
|
||||
|
Loading…
x
Reference in New Issue
Block a user