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,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...';
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,7 +3,7 @@
namespace DesignPatterns\More\EAV;
/**
* Interface ValueAccessInterface
* Interface ValueAccessInterface.
*/
interface ValueAccessInterface
{

View File

@@ -3,7 +3,7 @@
namespace DesignPatterns\More\EAV;
/**
* Interface ValueInterface
* Interface ValueInterface.
*/
interface ValueInterface
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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