Dominik Liebler 8eed6f9c21 Merge pull request #130 from nueckman/codestyle-1
codestyle - remove trailing whitespaces
2015-04-09 21:40:48 +02:00
..
2014-07-31 14:13:53 -05:00
2014-11-05 10:24:28 +01:00
2014-11-05 10:24:28 +01:00
2015-04-08 23:19:24 +02:00
2014-11-05 10:24:28 +01:00

Repository
==========

Purpose
-------

Mediates between the domain and data mapping layers using a
collection-like interface for accessing domain objects. 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. Repository also supports the objective of
achieving a clean separation and one-way dependency between the domain
and data mapping layers.

Examples
--------

-  Doctrine 2 ORM: there is Repository that mediates between Entity and
   DBAL and contains methods to retrieve objects
-  Laravel Framework

UML Diagram
-----------

.. image:: uml/uml.png
   :alt: Alt Repository UML Diagram
   :align: center

Code
----

You can also find these code on `GitHub`_

Post.php

.. literalinclude:: Post.php
   :language: php
   :linenos:

PostRepository.php

.. literalinclude:: PostRepository.php
   :language: php
   :linenos:

Storage.php

.. literalinclude:: Storage.php
   :language: php
   :linenos:

MemoryStorage.php

.. literalinclude:: MemoryStorage.php
   :language: php
   :linenos:

Test
----

.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/More/Repository