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

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