Skip to content

Commit

Permalink
Merge pull request #27 from matryoshka-model/develop
Browse files Browse the repository at this point in the history
v0.6.2
  • Loading branch information
leogr committed May 13, 2015
2 parents bfda9d7 + 9e04849 commit cd90ff0
Show file tree
Hide file tree
Showing 111 changed files with 305 additions and 199 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributions to Matryoshka library and its related modules (i.e. wrappers) are

You make our lives easier by sending us your contributions through github pull requests.

* Coding standard for the project is [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
* Coding standard for the project is [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md)

* Any contribution must provide tests for additional introduced conditions

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014, RipaClub
Copyright (c) 2014-2015, RipaClub
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Matryoshka
# Matryoshka

[![Latest Stable Version](http://img.shields.io/packagist/v/matryoshka-model/matryoshka.svg?style=flat-square)](https://packagist.org/packages/matryoshka-model/matryoshka) [![Total Downloads](https://img.shields.io/packagist/dt/matryoshka-model/matryoshka.svg?style=flat-square)](https://packagist.org/packages/matryoshka-model/matryoshka)

Expand All @@ -7,14 +7,14 @@
| [![Build Status](https://img.shields.io/travis/matryoshka-model/matryoshka/master.svg?style=flat-square)](https://travis-ci.org/matryoshka-model/matryoshka) | [![Build Status](https://img.shields.io/travis/matryoshka-model/matryoshka/develop.svg?style=flat-square)](https://travis-ci.org/matryoshka-model/matryoshka) |
| [![Coveralls branch](https://img.shields.io/coveralls/matryoshka-model/matryoshka/master.svg?style=flat-square)](https://coveralls.io/r/matryoshka-model/matryoshka?branch=master) | [![Coveralls branch](https://img.shields.io/coveralls/matryoshka-model/matryoshka/develop.svg?style=flat-square)](https://coveralls.io/r/matryoshka-model/matryoshka?branch=develop) |

Matryoshka is a lightweight framework that provides a standard and easy way to implement a model [service layer](http://martinfowler.com/eaaCatalog/serviceLayer.html).
Matryoshka is a lightweight framework that provides a standard and easy way to implement a model [service layer](http://martinfowler.com/eaaCatalog/serviceLayer.html).
Its layered design aims to provide a strong seperation between the persistence and the rest of your application, whether the datagateway you need to use (i.e. Zend\Db, MongoCollection, an ORM, a REST client or anything else).
In order to work with Matryoshka, developers need just to setup services using its comprehensive configuration system and implement very simple [criteria](http://en.wikipedia.org/wiki/Criteria_Pattern) interfaces.
Furthermore, a set of [wrapper](http://en.wikipedia.org/wiki/Wrapper_library) for common persistence systems are provided as separeted libraries.
Furthermore, a set of [wrapper](http://en.wikipedia.org/wiki/Wrapper_library) for common persistence systems are provided as separeted libraries.

## Theory of operation

Matryoshka doesn't provide a persistence layer implementation itself, but it can work with any third party implementation that acts as datagateway. Regardless of the datagateway you choose, Matryoshka provides to clients (i.e. your controller) the same set of handful API. To accomplish this goal Matryoshka uses criteria interfaces that developer have to implement.
Matryoshka doesn't provide a persistence layer implementation itself, but it can work with any third party implementation that acts as datagateway. Regardless of the datagateway you choose, Matryoshka provides to clients (i.e. your controller) the same set of handful API. To accomplish this goal Matryoshka uses criteria interfaces that developer have to implement.

Think a criteria as a small piece of code that tell to the datagateway how to perform an operation on your dataset: for example filter some rows. So, each criteria represent a simple task: different kind of criteria interfaces are defined for write, read and delete operations. Also, in concrete criteria classes, the developer can add methods to augment the "query interface" with domain specific logic.

Expand All @@ -24,16 +24,16 @@ So Matryoska is unawareness about the datagateway interface, that makes it worki

Matryoshka dolls (layers):

* ModelManager
* **ModelManager**
A dedicated service locator for your model service classes (i.e., model)

* Model
* **Model**
A service class representing a collection of entities that provides common features in a centralized way (e.g., CRUD, resultset, paginating, hydrating, input filtering)

* Criteria
* **Criteria**
An "user query intefarce" from an API point of view, also acting as mediator between model and datagateway

* Datagateway
* **Datagateway**
Any kind of datagateway, like `Zend\Db\TableGateway` or `\MongoCollection`

Basic usage example:
Expand All @@ -43,7 +43,7 @@ Basic usage example:
$myModel = $modelManager->get('MyModel');

//Assuming MyCriteria a class extending ReadableCriteriaInterface
$criteria = new MyCriteria();
$criteria = new MyCriteria();
$criteria->setMyCustomFilter('foo');

//Execute a query
Expand All @@ -59,7 +59,7 @@ Add the following to your `composer.json` file:
```
"require": {
"php": ">=5.4",
"matryoshka-model/matryoshka": "~0.6.0",
"matryoshka-model/matryoshka": "~0.6.2",
}
```

Expand Down
61 changes: 0 additions & 61 deletions docs/examples/mongo-find-extended.md

This file was deleted.

2 changes: 1 addition & 1 deletion library/AbstractModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model;
Expand Down
2 changes: 1 addition & 1 deletion library/Criteria/AbstractCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Criteria;
Expand Down
2 changes: 1 addition & 1 deletion library/Criteria/ActiveRecord/AbstractCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Criteria\ActiveRecord;
Expand Down
2 changes: 1 addition & 1 deletion library/Criteria/CallbackCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Criteria;
Expand Down
2 changes: 1 addition & 1 deletion library/Criteria/CriteriaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Criteria;
Expand Down
2 changes: 1 addition & 1 deletion library/Criteria/DeletableCriteriaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Criteria;
Expand Down
2 changes: 1 addition & 1 deletion library/Criteria/ExtractionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Criteria;
Expand Down
2 changes: 1 addition & 1 deletion library/Criteria/PaginableCriteriaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Criteria;
Expand Down
2 changes: 1 addition & 1 deletion library/Criteria/ReadableCriteriaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Criteria;
Expand Down
2 changes: 1 addition & 1 deletion library/Criteria/WritableCriteriaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Criteria;
Expand Down
2 changes: 1 addition & 1 deletion library/DataGatewayAwareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model;
Expand Down
2 changes: 1 addition & 1 deletion library/DataGatewayAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model;
Expand Down
2 changes: 1 addition & 1 deletion library/Exception/ErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Exception;
Expand Down
2 changes: 1 addition & 1 deletion library/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Exception;
Expand Down
2 changes: 1 addition & 1 deletion library/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Exception;
Expand Down
2 changes: 1 addition & 1 deletion library/Exception/InvalidPluginException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Exception;
Expand Down
2 changes: 1 addition & 1 deletion library/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Exception;
Expand Down
2 changes: 1 addition & 1 deletion library/Exception/ServiceNotCreatedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Exception;
Expand Down
2 changes: 1 addition & 1 deletion library/Exception/UnexpectedValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Exception;
Expand Down
2 changes: 1 addition & 1 deletion library/Hydrator/ClassMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Hydrator;
Expand Down
10 changes: 8 additions & 2 deletions library/Hydrator/Strategy/DateTimeStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Matryoshka
*
* @link https://github.com/matryoshka-model/matryoshka
* @copyright Copyright (c) 2014, Ripa Club
* @copyright Copyright (c) 2014-2015, Ripa Club
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
namespace Matryoshka\Model\Hydrator\Strategy;
Expand All @@ -21,6 +21,9 @@ class DateTimeStrategy implements StrategyInterface
*/
protected $format = DateTime::ISO8601;

/**
* @param string|null $format
*/
public function __construct($format = null)
{
if($format !== null) {
Expand All @@ -37,7 +40,10 @@ public function __construct($format = null)
public function hydrate($value)
{
if (is_string($value)) {
return DateTime::createFromFormat($this->getFormat(), $value);
$value = DateTime::createFromFormat($this->getFormat(), $value);
if ($value) {
return $value;
}
}
return null;
}
Expand Down

0 comments on commit cd90ff0

Please sign in to comment.