Applied fixes from StyleCI

This commit is contained in:
Dominik Liebler
2015-12-21 07:28:20 -05:00
committed by StyleCI Bot
parent 3663603b80
commit fe1f144ec3
167 changed files with 510 additions and 517 deletions

View File

@@ -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
{

View File

@@ -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()
{

View File

@@ -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
*/

View File

@@ -3,7 +3,7 @@
namespace DesignPatterns\Structural\Adapter;
/**
* Kindle is a concrete electronic book
* Kindle is a concrete electronic book.
*/
class Kindle implements EBookInterface
{

View File

@@ -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
*/

View File

@@ -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
*

View File

@@ -4,9 +4,8 @@ namespace DesignPatterns\Structural\Bridge;
class Assemble implements Workshop
{
public function work()
{
print 'Assembled';
echo 'Assembled';
}
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -3,13 +3,12 @@
namespace DesignPatterns\Structural\Bridge;
/**
* Concrete Implementation
* Concrete Implementation.
*/
class Produce implements Workshop
{
public function work()
{
print 'Produced ';
echo 'Produced ';
}
}

View File

@@ -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());

View File

@@ -3,11 +3,10 @@
namespace DesignPatterns\Structural\Bridge;
/**
* Abstraction
* Abstraction.
*/
abstract class Vehicle
{
protected $workShop1;
protected $workShop2;

View File

@@ -3,10 +3,9 @@
namespace DesignPatterns\Structural\Bridge;
/**
* Implementer
* Implementer.
*/
interface Workshop
{
public function work();
}

View File

@@ -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;

View File

@@ -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
*

View File

@@ -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) . '<input type="text" />';
return str_repeat(' ', $indent).'<input type="text" />';
}
}

View File

@@ -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()
{

View File

@@ -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';
}
}

View File

@@ -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())

View File

@@ -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
{

View File

@@ -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
*

View File

@@ -9,7 +9,7 @@ namespace DesignPatterns\Structural\Decorator;
*/
/**
* class Decorator
* class Decorator.
*/
abstract class Decorator implements RendererInterface
{

View File

@@ -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
*/

View File

@@ -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
*/

View File

@@ -3,12 +3,12 @@
namespace DesignPatterns\Structural\Decorator;
/**
* Class RendererInterface
* Class RendererInterface.
*/
interface RendererInterface
{
/**
* render data
* render data.
*
* @return mixed
*/

View File

@@ -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()
{

View File

@@ -3,7 +3,7 @@
namespace DesignPatterns\Structural\Decorator;
/**
* Class Webservice
* Class Webservice.
*/
class Webservice implements RendererInterface
{

View File

@@ -3,7 +3,7 @@
namespace DesignPatterns\Structural\DependencyInjection;
/**
* class AbstractConfig
* class AbstractConfig.
*/
abstract class AbstractConfig
{

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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()
{

View File

@@ -3,12 +3,12 @@
namespace DesignPatterns\Structural\Facade;
/**
* Class OsInterface
* Class OsInterface.
*/
interface OsInterface
{
/**
* halt the OS
* halt the OS.
*/
public function halt();
}

View File

@@ -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));
}

View File

@@ -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);
}
}

View File

@@ -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();

View File

@@ -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;
}
}
}

View File

@@ -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

View File

@@ -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)

View File

@@ -6,7 +6,6 @@ use DesignPatterns\Structural\Registry\Registry;
class RegistryTest extends \PHPUnit_Framework_TestCase
{
public function testSetAndGetLogger()
{
Registry::set(Registry::LOGGER, new \StdClass());