mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-05 22:47:34 +02:00
Applied fixes from StyleCI
This commit is contained in:
committed by
StyleCI Bot
parent
3663603b80
commit
fe1f144ec3
@@ -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)
|
||||
|
Reference in New Issue
Block a user