diff --git a/Behavioral/ChainOfResponsibilities/Handler.php b/Behavioral/ChainOfResponsibilities/Handler.php
index f080e23..679734e 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 @@ abstract class Handler
}
/**
- * 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 4a74642..8acaad1 100644
--- a/Behavioral/ChainOfResponsibilities/Responsible/FastStorage.php
+++ b/Behavioral/ChainOfResponsibilities/Responsible/FastStorage.php
@@ -6,7 +6,7 @@ use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler;
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 127b7fc..bd3f825 100644
--- a/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php
+++ b/Behavioral/ChainOfResponsibilities/Responsible/SlowStorage.php
@@ -6,14 +6,13 @@ use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler;
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 0e8357c..62d1172 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 @@ class ChainTest extends \PHPUnit_Framework_TestCase
$request->verb = 'get';
return array(
- array($request)
+ array($request),
);
}
diff --git a/Behavioral/Command/CommandInterface.php b/Behavioral/Command/CommandInterface.php
index ad9117b..cd9d9c6 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 831c299..94d4723 100644
--- a/Behavioral/Command/HelloCommand.php
+++ b/Behavioral/Command/HelloCommand.php
@@ -4,7 +4,7 @@ namespace DesignPatterns\Behavioral\Command;
/**
* 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 @@ class HelloCommand implements CommandInterface
}
/**
- * 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 4461ee2..7942adb 100644
--- a/Behavioral/Command/Invoker.php
+++ b/Behavioral/Command/Invoker.php
@@ -4,7 +4,7 @@ namespace DesignPatterns\Behavioral\Command;
/**
* Invoker is using the command given to it.
- * Example : an Application in SF2
+ * Example : an Application in SF2.
*/
class Invoker
{
@@ -25,7 +25,7 @@ class Invoker
}
/**
- * executes the command
+ * executes the command.
*/
public function run()
{
diff --git a/Behavioral/Command/Receiver.php b/Behavioral/Command/Receiver.php
index 9289369..ccf910b 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 abf7317..9d9aa51 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 a0d1114..b1adf7f 100644
--- a/Behavioral/Iterator/Book.php
+++ b/Behavioral/Iterator/Book.php
@@ -4,7 +4,6 @@ namespace DesignPatterns\Behavioral\Iterator;
class Book
{
-
private $author;
private $title;
@@ -27,6 +26,6 @@ class Book
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 6773f9b..6cc5e5e 100644
--- a/Behavioral/Iterator/BookList.php
+++ b/Behavioral/Iterator/BookList.php
@@ -4,7 +4,6 @@ namespace DesignPatterns\Behavioral\Iterator;
class BookList implements \Countable
{
-
private $books;
public function getBook($bookNumberToGet)
@@ -13,7 +12,7 @@ class BookList implements \Countable
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 93df6d7..ecedba6 100644
--- a/Behavioral/Iterator/BookListIterator.php
+++ b/Behavioral/Iterator/BookListIterator.php
@@ -4,7 +4,6 @@ namespace DesignPatterns\Behavioral\Iterator;
class BookListIterator implements \Iterator
{
-
/**
* @var BookList
*/
@@ -21,8 +20,10 @@ class BookListIterator implements \Iterator
}
/**
- * 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 @@ class BookListIterator implements \Iterator
/**
* (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 @@ class BookListIterator implements \Iterator
/**
* (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 @@ class BookListIterator implements \Iterator
/**
* (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 @@ class BookListIterator implements \Iterator
/**
* (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 d7ec49a..94f34d9 100644
--- a/Behavioral/Iterator/BookListReverseIterator.php
+++ b/Behavioral/Iterator/BookListReverseIterator.php
@@ -4,7 +4,6 @@ namespace DesignPatterns\Behavioral\Iterator;
class BookListReverseIterator implements \Iterator
{
-
/**
* @var BookList
*/
@@ -22,8 +21,10 @@ class BookListReverseIterator implements \Iterator
}
/**
- * 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 @@ class BookListReverseIterator implements \Iterator
/**
* (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 @@ class BookListReverseIterator implements \Iterator
/**
* (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 @@ class BookListReverseIterator implements \Iterator
/**
* (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 @@ class BookListReverseIterator implements \Iterator
/**
* (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 2c5acd9..db386f0 100644
--- a/Behavioral/Iterator/Tests/IteratorTest.php
+++ b/Behavioral/Iterator/Tests/IteratorTest.php
@@ -9,7 +9,6 @@ use DesignPatterns\Behavioral\Iterator\BookListReverseIterator;
class IteratorTest extends \PHPUnit_Framework_TestCase
{
-
/**
* @var BookList
*/
@@ -30,8 +29,8 @@ class IteratorTest extends \PHPUnit_Framework_TestCase
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 @@ class IteratorTest extends \PHPUnit_Framework_TestCase
}
/**
- * Test BookList Remove
+ * Test BookList Remove.
*/
public function testBookRemove()
{
diff --git a/Behavioral/Mediator/Colleague.php b/Behavioral/Mediator/Colleague.php
index c0ff248..c74dee5 100644
--- a/Behavioral/Mediator/Colleague.php
+++ b/Behavioral/Mediator/Colleague.php
@@ -9,12 +9,12 @@ namespace DesignPatterns\Behavioral\Mediator;
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 @@ abstract class Colleague
}
// for subclasses
+
protected function getMediator()
{
return $this->mediator;
diff --git a/Behavioral/Mediator/Mediator.php b/Behavioral/Mediator/Mediator.php
index ba1407e..98a7890 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 @@ class Mediator implements MediatorInterface
}
/**
- * make request
+ * make request.
*/
public function makeRequest()
{
@@ -47,7 +44,8 @@ class Mediator implements MediatorInterface
}
/**
- * query db
+ * query db.
+ *
* @return mixed
*/
public function queryDb()
@@ -56,7 +54,7 @@ class Mediator implements MediatorInterface
}
/**
- * send response
+ * send response.
*
* @param string $content
*/
diff --git a/Behavioral/Mediator/MediatorInterface.php b/Behavioral/Mediator/MediatorInterface.php
index b289cea..dbdd489 100644
--- a/Behavioral/Mediator/MediatorInterface.php
+++ b/Behavioral/Mediator/MediatorInterface.php
@@ -4,24 +4,24 @@ namespace DesignPatterns\Behavioral\Mediator;
/**
* 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 cb4b020..f7a21c9 100644
--- a/Behavioral/Mediator/Subsystem/Client.php
+++ b/Behavioral/Mediator/Subsystem/Client.php
@@ -5,12 +5,12 @@ namespace DesignPatterns\Behavioral\Mediator\Subsystem;
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 @@ class Client extends Colleague
}
/**
- * output content
+ * output content.
*
* @param string $content
*/
diff --git a/Behavioral/Mediator/Subsystem/Database.php b/Behavioral/Mediator/Subsystem/Database.php
index 7cc9bc4..69ad6cf 100644
--- a/Behavioral/Mediator/Subsystem/Database.php
+++ b/Behavioral/Mediator/Subsystem/Database.php
@@ -5,7 +5,7 @@ namespace DesignPatterns\Behavioral\Mediator\Subsystem;
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 1638301..1602bcb 100644
--- a/Behavioral/Mediator/Subsystem/Server.php
+++ b/Behavioral/Mediator/Subsystem/Server.php
@@ -5,12 +5,12 @@ namespace DesignPatterns\Behavioral\Mediator\Subsystem;
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 13abe48..2bce947 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 72530fb..d80454a 100644
--- a/Behavioral/Memento/Caretaker.php
+++ b/Behavioral/Memento/Caretaker.php
@@ -27,19 +27,19 @@ class Caretaker
$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 3ea82b1..722dbfa 100644
--- a/Behavioral/Memento/Tests/MementoTest.php
+++ b/Behavioral/Memento/Tests/MementoTest.php
@@ -7,11 +7,10 @@ use DesignPatterns\Behavioral\Memento\Memento;
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 @@ class MementoTest extends \PHPUnit_Framework_TestCase
$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 @@ class MementoTest extends \PHPUnit_Framework_TestCase
$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 @@ class MementoTest extends \PHPUnit_Framework_TestCase
$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 @@ class MementoTest extends \PHPUnit_Framework_TestCase
$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 @@ class MementoTest extends \PHPUnit_Framework_TestCase
$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 216d838..99a28c7 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 a088145..371c1ab 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 ae6d96d..56a3847 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 @@ class Service
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 a8e7bf5..034b577 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 75490cc..d9dacec 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 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
}
/**
- * Tests the notification
+ * Tests the notification.
*/
public function testNotify()
{
@@ -31,7 +30,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
}
/**
- * Tests the subscribing
+ * Tests the subscribing.
*/
public function testAttachDetach()
{
@@ -53,7 +52,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
}
/**
- * 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 213f229..0d2a817 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 @@ class User implements \SplSubject
}
/**
- * detach an observer
+ * detach an observer.
*
* @param \SplObserver $observer
*
@@ -54,7 +53,7 @@ class User implements \SplSubject
}
/**
- * notify observers
+ * notify observers.
*
* @return void
*/
@@ -68,7 +67,7 @@ class User implements \SplSubject
/**
* 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 f444604..f2673ba 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 f297539..66d61b8 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 4831b18..1911ba4 100644
--- a/Behavioral/Strategy/Tests/StrategyTest.php
+++ b/Behavioral/Strategy/Tests/StrategyTest.php
@@ -8,21 +8,20 @@ use DesignPatterns\Behavioral\Strategy\ObjectCollection;
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 @@ class StrategyTest extends \PHPUnit_Framework_TestCase
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 94018f3..d19845c 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 89c2ef0..3f36b61 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 cec9a7d..6309e7f 100644
--- a/Behavioral/TemplateMethod/Journey.php
+++ b/Behavioral/TemplateMethod/Journey.php
@@ -23,7 +23,7 @@ abstract class Journey
}
/**
- * 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 @@ abstract class Journey
}
/**
- * This method will be unknown by subclasses (better)
+ * This method will be unknown by subclasses (better).
*/
private function buyAFlight()
{
@@ -46,7 +46,7 @@ abstract class Journey
/**
* 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 d0b134c..82acef3 100644
--- a/Behavioral/TemplateMethod/Tests/JourneyTest.php
+++ b/Behavioral/TemplateMethod/Tests/JourneyTest.php
@@ -5,11 +5,10 @@ namespace DesignPatterns\Behavioral\TemplateMethod\Tests;
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 @@ class JourneyTest extends \PHPUnit_Framework_TestCase
}
/**
- * 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 3990f9c..b2c9d90 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 @@ class Group extends Role
*/
public function getName()
{
- return "Group: " . $this->name;
+ return 'Group: '.$this->name;
}
}
diff --git a/Behavioral/Visitor/Role.php b/Behavioral/Visitor/Role.php
index fd0d0a4..011a0fb 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 @@ abstract class Role
// this trick to simulate double-dispatch based on type-hinting
$klass = get_called_class();
preg_match('#([^\\\\]+)$#', $klass, $extract);
- $visitingMethod = 'visit' . $extract[1];
+ $visitingMethod = 'visit'.$extract[1];
// this ensures strong typing with visitor interface, not some visitor objects
- if (!method_exists(__NAMESPACE__ . '\RoleVisitorInterface', $visitingMethod)) {
+ if (!method_exists(__NAMESPACE__.'\RoleVisitorInterface', $visitingMethod)) {
throw new \InvalidArgumentException("The visitor you provide cannot visit a $klass instance");
}
diff --git a/Behavioral/Visitor/RolePrintVisitor.php b/Behavioral/Visitor/RolePrintVisitor.php
index 5f07d5c..49777cf 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 @@ class RolePrintVisitor implements RoleVisitorInterface
*/
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 b007b13..1a72d7e 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 @@ namespace DesignPatterns\Behavioral\Visitor;
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 6d71658..f3b5bc7 100644
--- a/Behavioral/Visitor/Tests/VisitorTest.php
+++ b/Behavioral/Visitor/Tests/VisitorTest.php
@@ -5,11 +5,10 @@ namespace DesignPatterns\Tests\Visitor\Tests;
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 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
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 e0cc4c7..5a95fbe 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 @@ class User extends Role
*/
public function getName()
{
- return "User " . $this->name;
+ return 'User '.$this->name;
}
}
diff --git a/Creational/AbstractFactory/AbstractFactory.php b/Creational/AbstractFactory/AbstractFactory.php
index 49982e5..6529ff6 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 @@ namespace DesignPatterns\Creational\AbstractFactory;
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 9d7f440..3abacb4 100644
--- a/Creational/AbstractFactory/Html/Picture.php
+++ b/Creational/AbstractFactory/Html/Picture.php
@@ -5,14 +5,14 @@ namespace DesignPatterns\Creational\AbstractFactory\Html;
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 120c043..8c33da6 100644
--- a/Creational/AbstractFactory/Html/Text.php
+++ b/Creational/AbstractFactory/Html/Text.php
@@ -5,19 +5,19 @@ namespace DesignPatterns\Creational\AbstractFactory\Html;
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 7982a24..5c22859 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 @@ class HtmlFactory extends AbstractFactory
}
/**
- * 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 13d191b..77bb150 100644
--- a/Creational/AbstractFactory/Json/Picture.php
+++ b/Creational/AbstractFactory/Json/Picture.php
@@ -5,14 +5,14 @@ namespace DesignPatterns\Creational\AbstractFactory\Json;
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 699fff3..4c51785 100644
--- a/Creational/AbstractFactory/Json/Text.php
+++ b/Creational/AbstractFactory/Json/Text.php
@@ -5,14 +5,14 @@ namespace DesignPatterns\Creational\AbstractFactory\Json;
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 ab2bb6f..63a9979 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 @@ class JsonFactory extends AbstractFactory
}
/**
- * Creates a text component
+ * Creates a text component.
*
* @param string $content
*
diff --git a/Creational/AbstractFactory/MediaInterface.php b/Creational/AbstractFactory/MediaInterface.php
index 6bb5d3a..aa73f1b 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 8a4f720..89fd66f 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 b51394a..97f4417 100644
--- a/Creational/AbstractFactory/Tests/AbstractFactoryTest.php
+++ b/Creational/AbstractFactory/Tests/AbstractFactoryTest.php
@@ -7,7 +7,7 @@ use DesignPatterns\Creational\AbstractFactory\HtmlFactory;
use DesignPatterns\Creational\AbstractFactory\JsonFactory;
/**
- * AbstractFactoryTest tests concrete factories
+ * AbstractFactoryTest tests concrete factories.
*/
class AbstractFactoryTest extends \PHPUnit_Framework_TestCase
{
@@ -15,7 +15,7 @@ class AbstractFactoryTest extends \PHPUnit_Framework_TestCase
{
return array(
array(new JsonFactory()),
- array(new HtmlFactory())
+ array(new HtmlFactory()),
);
}
@@ -31,7 +31,7 @@ class AbstractFactoryTest extends \PHPUnit_Framework_TestCase
$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 5d2da89..30984f3 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 53d53d3..f83c5db 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 7725176..a0693d0 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 3d125d9..642cd1b 100644
--- a/Creational/Builder/Director.php
+++ b/Creational/Builder/Director.php
@@ -10,9 +10,8 @@ namespace DesignPatterns\Creational\Builder;
*/
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 6efefe9..e5adbba 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 1d4496c..e345ea9 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 526d41b..fc12608 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 0b2fad0..5232ab3 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 492eade..487be57 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 7fb60fd..0a1afbd 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 0520bfe..9f07b83 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 @@ class DirectorTest extends \PHPUnit_Framework_TestCase
{
return array(
array(new CarBuilder()),
- array(new BikeBuilder())
+ array(new BikeBuilder()),
);
}
diff --git a/Creational/FactoryMethod/Bicycle.php b/Creational/FactoryMethod/Bicycle.php
index 01fa8a0..8e41f88 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 dd24b15..fa3d4a3 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 class FactoryMethod
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 c905f91..9434e3d 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 67306e9..1f65eb4 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 c7010e0..25eeaf1 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 cba25ce..bdabb87 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 acbe0c6..6b1c4d2 100644
--- a/Creational/FactoryMethod/Tests/FactoryMethodTest.php
+++ b/Creational/FactoryMethod/Tests/FactoryMethodTest.php
@@ -7,21 +7,20 @@ use DesignPatterns\Creational\FactoryMethod\GermanFactory;
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 a734b61..ccb05ee 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 44f1ef0..5338e62 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 @@ class Multiton
/**
* 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 @@ class Multiton
}
/**
- * prevent instance from being cloned
+ * prevent instance from being cloned.
*
* @return void
*/
@@ -61,7 +58,7 @@ class Multiton
}
/**
- * 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 e3a809b..7dcc6e3 100644
--- a/Creational/Pool/Pool.php
+++ b/Creational/Pool/Pool.php
@@ -4,7 +4,6 @@ namespace DesignPatterns\Creational\Pool;
class Pool
{
-
private $instances = array();
private $class;
diff --git a/Creational/Pool/Processor.php b/Creational/Pool/Processor.php
index 957e91f..89179b9 100644
--- a/Creational/Pool/Processor.php
+++ b/Creational/Pool/Processor.php
@@ -4,11 +4,10 @@ namespace DesignPatterns\Creational\Pool;
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 acdc1ba..08d76b8 100644
--- a/Creational/Pool/Worker.php
+++ b/Creational/Pool/Worker.php
@@ -4,7 +4,6 @@ namespace DesignPatterns\Creational\Pool;
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 4354a60..7c9b72b 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 18d4871..e0fafa6 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 9707bfd..95ea9e6 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 f268e5c..d0f6e94 100644
--- a/Creational/Prototype/index.php
+++ b/Creational/Prototype/index.php
@@ -8,10 +8,10 @@ $barPrototype = new BarBookPrototype();
// 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 67215f1..defa801 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 dd8acf8..5f4cd2d 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 81fa505..e1db734 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 1fffda3..c913d96 100644
--- a/Creational/SimpleFactory/Tests/SimpleFactoryTest.php
+++ b/Creational/SimpleFactory/Tests/SimpleFactoryTest.php
@@ -5,11 +5,10 @@ namespace DesignPatterns\Creational\SimpleFactory\Tests;
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 @@ class SimpleFactoryTest extends \PHPUnit_Framework_TestCase
{
return array(
array('bicycle'),
- array('other')
+ array('other'),
);
}
diff --git a/Creational/SimpleFactory/VehicleInterface.php b/Creational/SimpleFactory/VehicleInterface.php
index eb13a66..f2c8d3f 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 94f7a0a..650810e 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 @@ class Singleton
/**
* 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 38be5e6..b025b4a 100644
--- a/Creational/Singleton/SingletonPatternViolationException.php
+++ b/Creational/Singleton/SingletonPatternViolationException.php
@@ -4,5 +4,4 @@ namespace DesignPatterns\Creational\Singleton;
class SingletonPatternViolationException extends \Exception
{
-
}
diff --git a/Creational/Singleton/Tests/SingletonTest.php b/Creational/Singleton/Tests/SingletonTest.php
index 122d4dc..6b72285 100644
--- a/Creational/Singleton/Tests/SingletonTest.php
+++ b/Creational/Singleton/Tests/SingletonTest.php
@@ -5,11 +5,10 @@ namespace DesignPatterns\Creational\Singleton\Tests;
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 @@ class SingletonTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \DesignPatterns\Creational\Singleton\SingletonPatternViolationException
+ *
* @return void
*/
public function testNoCloneAllowed()
@@ -39,6 +39,7 @@ class SingletonTest extends \PHPUnit_Framework_TestCase
/**
* @expectedException \DesignPatterns\Creational\Singleton\SingletonPatternViolationException
+ *
* @return void
*/
public function testNoSerializationAllowed()
diff --git a/Creational/StaticFactory/FormatNumber.php b/Creational/StaticFactory/FormatNumber.php
index 8f382f7..e577ab2 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 a0d174d..5cb9e28 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 81b9149..349f8b6 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 e4f2f96..e4c4f4b 100644
--- a/Creational/StaticFactory/StaticFactory.php
+++ b/Creational/StaticFactory/StaticFactory.php
@@ -4,23 +4,24 @@ namespace DesignPatterns\Creational\StaticFactory;
/**
* 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 f0304ca..61f65af 100644
--- a/Creational/StaticFactory/Tests/StaticFactoryTest.php
+++ b/Creational/StaticFactory/Tests/StaticFactoryTest.php
@@ -5,17 +5,15 @@ namespace DesignPatterns\Creational\StaticFactory\Tests;
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 @@ class StaticFactoryTest extends \PHPUnit_Framework_TestCase
*/
public function testException()
{
- StaticFactory::factory("");
+ StaticFactory::factory('');
}
}
diff --git a/More/Delegation/JuniorDeveloper.php b/More/Delegation/JuniorDeveloper.php
index 7506181..0946dad 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 315bd3b..9b75190 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 @@ class TeamLead
}
/**
- * 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 b19f871..7d0a33b 100644
--- a/More/Delegation/Tests/DelegationTest.php
+++ b/More/Delegation/Tests/DelegationTest.php
@@ -5,7 +5,7 @@ namespace DesignPatterns\More\Delegation\Tests;
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 7a1a88e..3874360 100644
--- a/More/EAV/Attribute.php
+++ b/More/EAV/Attribute.php
@@ -5,7 +5,7 @@ namespace DesignPatterns\More\EAV;
use SplObjectStorage;
/**
- * Class Attribute
+ * Class Attribute.
*/
class Attribute implements ValueAccessInterface
{
@@ -34,6 +34,7 @@ class Attribute implements ValueAccessInterface
/**
* @param ValueInterface $value
+ *
* @return $this
*/
public function addValue(ValueInterface $value)
@@ -47,6 +48,7 @@ class Attribute implements ValueAccessInterface
/**
* @param ValueInterface $value
+ *
* @return $this
*/
public function removeValue(ValueInterface $value)
@@ -68,6 +70,7 @@ class Attribute implements ValueAccessInterface
/**
* @param string $name
+ *
* @return $this
*/
public function setName($name)
diff --git a/More/EAV/Entity.php b/More/EAV/Entity.php
index e92444e..ff26589 100644
--- a/More/EAV/Entity.php
+++ b/More/EAV/Entity.php
@@ -5,7 +5,7 @@ namespace DesignPatterns\More\EAV;
use SplObjectStorage;
/**
- * Class Entity
+ * Class Entity.
*/
class Entity implements ValueAccessInterface
{
@@ -34,6 +34,7 @@ class Entity implements ValueAccessInterface
/**
* @param ValueInterface $value
+ *
* @return $this
*/
public function addValue(ValueInterface $value)
@@ -47,6 +48,7 @@ class Entity implements ValueAccessInterface
/**
* @param ValueInterface $value
+ *
* @return $this
*/
public function removeValue(ValueInterface $value)
@@ -68,6 +70,7 @@ class Entity implements ValueAccessInterface
/**
* @param string $name
+ *
* @return $this
*/
public function setName($name)
diff --git a/More/EAV/Tests/AttributeTest.php b/More/EAV/Tests/AttributeTest.php
index 7e7efec..4affe41 100644
--- a/More/EAV/Tests/AttributeTest.php
+++ b/More/EAV/Tests/AttributeTest.php
@@ -6,7 +6,7 @@ use DesignPatterns\More\EAV\Attribute;
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 42c10f3..ecd6c40 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 @@ class EntityTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider valueProvider
*
- * @var string $name
+ * @var string
* @var Value[] $values
*/
public function testAddValue($name, array $values)
@@ -47,7 +47,7 @@ class EntityTest extends \PHPUnit_Framework_TestCase
* @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 1b96521..f80f070 100644
--- a/More/EAV/Tests/ValueTest.php
+++ b/More/EAV/Tests/ValueTest.php
@@ -6,7 +6,7 @@ use DesignPatterns\More\EAV\Attribute;
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 127f8ce..2c156a9 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 @@ class Value implements ValueInterface
/**
* @param Attribute $attribute
+ *
* @return $this
*/
public function setAttribute(Attribute $attribute)
@@ -57,6 +58,7 @@ class Value implements ValueInterface
/**
* @param string $name
+ *
* @return $this
*/
public function setName($name)
diff --git a/More/EAV/ValueAccessInterface.php b/More/EAV/ValueAccessInterface.php
index 27820a8..dde67b2 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 c041835..3737f67 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 c5bb5c4..32ba5de 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 @@ $mac = (new Entity())
->addValue($memory8Gb)
// storages
->addValue($storage256Gb)
- ->addValue($storage512Gb)
-;
+ ->addValue($storage512Gb);
$macAir = (new Entity())
->setName('MacBook Air')
@@ -52,8 +51,7 @@ $macAir = (new Entity())
// storages
->addValue($storage128Gb)
->addValue($storage256Gb)
- ->addValue($storage512Gb)
-;
+ ->addValue($storage512Gb);
$macPro = (new Entity())
->setName('MacBook Pro')
@@ -66,5 +64,4 @@ $macPro = (new Entity())
->addValue($storage128Gb)
->addValue($storage256Gb)
->addValue($storage512Gb)
- ->addValue($storage1Tb)
-;
+ ->addValue($storage1Tb);
diff --git a/More/Repository/MemoryStorage.php b/More/Repository/MemoryStorage.php
index 1da09bc..44276d5 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 @@ class MemoryStorage implements Storage
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 9435d2e..e9990b4 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 8b0ddac..e7687f3 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 @@ use DesignPatterns\More\Repository\Storage;
* between the domain and data mapping layers
*
* Class PostRepository
- * @package DesignPatterns\Repository
*/
class PostRepository
{
@@ -27,16 +24,17 @@ class PostRepository
}
/**
- * 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 @@ class PostRepository
}
/**
- * 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 @@ class PostRepository
'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 4d528b4..a730f09 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 6699eca..b631479 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 @@ class ServiceLocator implements ServiceLocatorInterface
$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 @@ class ServiceLocator implements ServiceLocatorInterface
*/
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 @@ class ServiceLocator implements ServiceLocatorInterface
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 d6b7ef6..72f8607 100644
--- a/More/ServiceLocator/Tests/ServiceLocatorTest.php
+++ b/More/ServiceLocator/Tests/ServiceLocatorTest.php
@@ -5,7 +5,7 @@ namespace DesignPatterns\More\ServiceLocator\Tests;
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 ae3c6dc..6458beb 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 a6c6476..3e4564a 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 @@ class EBookAdapter implements PaperBookInterface
}
/**
- * 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 @@ class EBookAdapter implements PaperBookInterface
}
/**
- * turns pages
+ * turns pages.
*/
public function turnPage()
{
diff --git a/Structural/Adapter/EBookInterface.php b/Structural/Adapter/EBookInterface.php
index 15e0222..bd3dc26 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 14dc485..06d4489 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 12f3103..4b62149 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 ecbc9e2..fd7713b 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 @@ class AdapterTest extends \PHPUnit_Framework_TestCase
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 2b60889..9b9d114 100644
--- a/Structural/Bridge/Assemble.php
+++ b/Structural/Bridge/Assemble.php
@@ -4,9 +4,8 @@ namespace DesignPatterns\Structural\Bridge;
class Assemble implements Workshop
{
-
public function work()
{
- print 'Assembled';
+ echo 'Assembled';
}
}
diff --git a/Structural/Bridge/Car.php b/Structural/Bridge/Car.php
index 2754199..89be431 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 @@ class Car extends Vehicle
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 b021ce6..f008785 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 @@ class Motorcycle extends Vehicle
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 b2b0505..a382f2d 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 e07afe9..0a89a86 100644
--- a/Structural/Bridge/Tests/BridgeTest.php
+++ b/Structural/Bridge/Tests/BridgeTest.php
@@ -9,7 +9,6 @@ use DesignPatterns\Structural\Bridge\Produce;
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 10b0d03..f519d70 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 dc62886..9cb26c5 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 fbf3b50..42f1bc1 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 @@ class Form extends FormElement
$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 8063c89..0055aee 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 30d8615..19786d5 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 f3ee1d1..510a06b 100644
--- a/Structural/Composite/Tests/CompositeTest.php
+++ b/Structural/Composite/Tests/CompositeTest.php
@@ -5,11 +5,10 @@ namespace DesignPatterns\Structural\Composite\Tests;
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 @@ class CompositeTest extends \PHPUnit_Framework_TestCase
/**
* 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 ed50294..48b33ba 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 fb531e9..551c11e 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 @@ class DataMapperTest extends \PHPUnit_Framework_TestCase
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 78e60a8..8d8d2b2 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 0ee5352..f147063 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 @@ class UserMapper
}
/**
- * 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 @@ class UserMapper
/**
* 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 @@ class UserMapper
/**
* 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 @@ class UserMapper
}
/**
- * 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 182c07a..0b8fde3 100644
--- a/Structural/Decorator/Decorator.php
+++ b/Structural/Decorator/Decorator.php
@@ -9,7 +9,7 @@ namespace DesignPatterns\Structural\Decorator;
*/
/**
- * class Decorator
+ * class Decorator.
*/
abstract class Decorator implements RendererInterface
{
diff --git a/Structural/Decorator/RenderInJson.php b/Structural/Decorator/RenderInJson.php
index ebcc577..71943bd 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 f8e92a0..2eab7ca 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 2957970..92b00ef 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 c50181f..689caf2 100644
--- a/Structural/Decorator/Tests/DecoratorTest.php
+++ b/Structural/Decorator/Tests/DecoratorTest.php
@@ -5,11 +5,10 @@ namespace DesignPatterns\Structural\Decorator\Tests;
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 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase
}
/**
- * The first key-point of this pattern :
+ * The first key-point of this pattern :.
*/
public function testDecoratorMustImplementsRenderer()
{
@@ -45,7 +44,7 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase
}
/**
- * 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 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase
}
/**
- * 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 @@ class DecoratorTest extends \PHPUnit_Framework_TestCase
}
/**
- * 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 e6bf306..e2bcc69 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 85e5245..f2da4dc 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 91bca33..f26c089 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 @@ class ArrayConfig extends AbstractConfig implements Parameters
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 9e131c2..d389089 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 @@ class Connection
}
/**
- * connection using the injected config
+ * connection using the injected config.
*/
public function connect()
{
@@ -42,6 +42,7 @@ class Connection
*
* @return string
*/
+
public function getHost()
{
return $this->host;
diff --git a/Structural/DependencyInjection/Parameters.php b/Structural/DependencyInjection/Parameters.php
index dabe895..c49f4c7 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 869dcd9..823af04 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 c0048b4..50c665d 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 @@ class Facade
}
/**
- * turn on the system
+ * turn on the system.
*/
public function turnOn()
{
@@ -42,7 +41,7 @@ class Facade
}
/**
- * turn off the system
+ * turn off the system.
*/
public function turnOff()
{
diff --git a/Structural/Facade/OsInterface.php b/Structural/Facade/OsInterface.php
index 3b09eb1..8394fd4 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 18133e9..e6038a0 100644
--- a/Structural/Facade/Tests/FacadeTest.php
+++ b/Structural/Facade/Tests/FacadeTest.php
@@ -6,11 +6,10 @@ use DesignPatterns\Structural\Facade\Facade as Computer;
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 @@ class FacadeTest extends \PHPUnit_Framework_TestCase
->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 35af3ef..58ba491 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 @@ class Sql
}
/**
- * adds a FROM clause
+ * adds a FROM clause.
*
* @param string $table
* @param string $alias
@@ -46,13 +46,13 @@ class Sql
*/
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 @@ class Sql
/**
* 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 98ea99d..ae4e656 100644
--- a/Structural/FluentInterface/Tests/FluentInterfaceTest.php
+++ b/Structural/FluentInterface/Tests/FluentInterfaceTest.php
@@ -5,11 +5,10 @@ namespace DesignPatterns\Structural\FluentInterface\Tests;
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 38481aa..7ae4a3c 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 @@ class Record
}
/**
- * magic setter
+ * magic setter.
*
* @param string $name
* @param mixed $value
@@ -34,7 +34,7 @@ class Record
}
/**
- * magic getter
+ * magic getter.
*
* @param string $name
*
@@ -45,7 +45,7 @@ class Record
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 1f68cff..f8c78a8 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 @@ class RecordProxy extends Record
}
/**
- * magic setter
+ * magic setter.
*
* @param string $name
* @param mixed $value
diff --git a/Structural/Registry/Registry.php b/Structural/Registry/Registry.php
index d1c6b13..e40d0c3 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 @@ abstract class Registry
}
/**
- * 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 64685d4..e889976 100644
--- a/Structural/Registry/Tests/RegistryTest.php
+++ b/Structural/Registry/Tests/RegistryTest.php
@@ -6,7 +6,6 @@ use DesignPatterns\Structural\Registry\Registry;
class RegistryTest extends \PHPUnit_Framework_TestCase
{
-
public function testSetAndGetLogger()
{
Registry::set(Registry::LOGGER, new \StdClass());