2017 © Pedro PelĂĄez
 

library repository

Implementation of a base repository

image

nilportugues/repository

Implementation of a base repository

  • Friday, March 3, 2017
  • by nilportugues
  • Repository
  • 2 Watchers
  • 23 Stars
  • 1,111 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 20 Versions
  • 2 % Grown

The README.md

Repository

PHP7 Tested Build Status Scrutinizer Code Quality SensioLabsInsight Latest Stable Version Total Downloads License Donate, (*1)

Generic implementation and definition of a Repository and its in-memory implementation., (*2)

Installation

Use Composer to install the package:, (*3)

$ composer require nilportugues/repository

InMemory Implementation

A custom repository can be easily created by extending the InMemoryRepository class provided., (*4)

use NilPortugues\Foundation\Infrastructure\Model\Repository\InMemory\InMemoryRepository

class MyInMemoryRepository extends InMemoryRepository
{
    //... your custom implementation.
}

Implementation can be seen here., (*5)

The base InMemoryRepository implements the following interfaces:, (*6)

  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\Repository
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\PageRepository
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\ReadRepository
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\WriteRepository

InMemoryRepository Example

An example with a complete implementation can be found in the /example directory., (*7)

In the example:, (*8)

  • Colors are defined as a class implementing the Identity interface.
  • A ColorRepository is implemented. Will throw exception if Color is not found.
  • Examples on how to filter are provided in the example.php file.

Foundation Classes

Interaction with the repository requires the usage of the following classes or classes implementing interfaces., (*9)

  • NilPortugues\Foundation\Domain\Model\Repository\Fields, (*10)

    • public function __construct(array $fields = [])
    • public function add($field)
    • public function get()
  • NilPortugues\Foundation\Domain\Model\Repository\Filter, (*11)

    • public function filters()
    • public function must()
    • public function mustNot()
    • public function should()
    • public function clear()
  • NilPortugues\Foundation\Domain\Model\Repository\BaseFilter, (*12)

    • public function notStartsWith($filterName, $value)
    • public function notEndsWith($filterName, $value)
    • public function notEmpty($filterName)
    • public function empty($filterName)
    • public function notNull($filterName)
    • public function empty($filterName)
    • public function startsWith($filterName, $value)
    • public function endsWith($filterName, $value)
    • public function equal($filterName, $value)
    • public function notEqual($filterName, $value)
    • public function includeGroup($filterName, array $value)
    • public function notIncludeGroup($filterName, array $value)
    • public function range($filterName, $firstValue, $secondValue)
    • public function notRange($filterName, $firstValue, $secondValue)
    • public function notContain($filterName, $value)
    • public function contain($filterName, $value)
    • public function beGreaterThanOrEqual($filterName, $value)
    • public function beGreaterThan($filterName, $value)
    • public function beLessThanOrEqual($filterName, $value)
    • public function beLessThan($filterName, $value)
    • public function clear()
    • public function get()
    • public function hasEmpty($filterName) //alias of empty() for BC reasons.
  • NilPortugues\Foundation\Domain\Model\Repository\Order, (*13)

    • public function __construct($direction)
    • public function isDescending()
    • public function isAscending()
    • public function __toString()
    • public function equals($object)
    • public function direction()
  • NilPortugues\Foundation\Domain\Model\Repository\Pageable, (*14)

    • public function __construct($pageNumber, $pageSize, SortInterface $sort = null, FilterInterface $filter = null, FieldsInterface $fields = null)
    • public function offset()
    • public function pageNumber()
    • public function sortings()
    • public function next()
    • public function pageSize()
    • public function previousOrFirst()
    • public function hasPrevious()
    • public function first()
    • public function filters()
    • public function fields()
  • NilPortugues\Foundation\Domain\Model\Repository\Page, (*15)

    • public function __construct(array $elements, $totalElements, $pageNumber, $totalPages, SortInterface $sort = null, FilterInterface $filter = null, FieldsInterface $fields = null)
    • public function content()
    • public function hasPrevious()
    • public function isFirst()
    • public function isLast()
    • public function hasNext()
    • public function pageSize()
    • public function pageNumber()
    • public function totalPages()
    • public function nextPageable()
    • public function sortings()
    • public function filters()
    • public function fields()
    • public function previousPageable()
    • public function totalElements()
    • public function map(callable $converter)
  • NilPortugues\Foundation\Domain\Model\Repository\Sort, (*16)

    • public function __construct(array $properties = [], OrderInterface $order = null)
    • public function andSort(SortInterface $sort)
    • public function orders()
    • public function equals(SortInterface $sort)
    • public function orderFor($propertyName)
    • public function setOrderFor($propertyName, OrderInterface $order)
    • public function property($propertyName)

Interfaces

  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\Identity, (*17)

    • public function id()
    • public function __toString()
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\Repository, (*18)

    • public function count(Filter $filter = null)
    • public function exists(Identity $id)
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\PageRepository, (*19)

    • public function findAll(Pageable $pageable = null)
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\ReadRepository, (*20)

    • public function find(Identity $id, Fields $fields = null)
    • public function findBy(Filter $filter = null, Sort $sort = null, Fields $fields = null)
    • public function findByDistinct(Fields $distinctFields, Filter $filter = null, Sort $sort = null, Fields $fields = null)
  • NilPortugues\Foundation\Domain\Model\Repository\Contracts\WriteRepository, (*21)

    • public function add($value)
    • public function addAll(array $values)
    • public function remove(Identity $id)
    • public function removeAll(Filter $filter = null)
    • public function transactional(callable $transaction)

Quality

To run the PHPUnit tests at the command line, go to the tests directory and issue phpunit., (*22)

This library attempts to comply with PSR-1, PSR-2, PSR-4., (*23)

If you notice compliance oversights, please send a patch via Pull Request., (*24)

Contribute

Contributions to the package are always welcome!, (*25)

Support

Get in touch with me using one of the following means:, (*26)

Authors

License

The code base is licensed under the MIT license., (*27)

The Versions

03/03 2017

dev-master

9999999-dev http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

03/03 2017

3.1.0

3.1.0.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

05/08 2016

3.0.2

3.0.2.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

05/08 2016

3.0.1

3.0.1.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

05/08 2016

3.0.0

3.0.0.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

10/05 2016

2.3.1

2.3.1.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

29/04 2016

2.3.0

2.3.0.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

29/03 2016

2.2.1

2.2.1.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

18/03 2016

2.2.0

2.2.0.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

18/03 2016

2.1.1

2.1.1.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

18/03 2016

2.1.0

2.1.0.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

27/02 2016

2.0.3

2.0.3.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

19/02 2016

2.0.2

2.0.2.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

16/02 2016

2.0.1

2.0.1.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

11/02 2016

2.0.0

2.0.0.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

06/02 2016

1.1.2

1.1.2.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

27/01 2016

1.1.1

1.1.1.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

26/01 2016

1.1.0

1.1.0.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

25/01 2016

1.0.0

1.0.0.0 http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable

18/01 2016

1.0.0-beta

1.0.0.0-beta http://nilportugues.com

Implementation of a base repository

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Nil Portugués

repository pagination ddd hexagonal adapters nil portugues nilportugues ports and adapters ports pageable