Skip to content

Documentation/Add installation and usage instructions. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ on:
jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "7.4"
- "8.0"
php-version: [ 7.4, 8.0, 8.1 ]

steps:
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install PHP
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
Expand All @@ -38,16 +37,17 @@ jobs:
- name: Install Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Execute Static Code analysis
run: composer analyse

- name: Execute Unit, Integration and Acceptance Tests
run: composer test

- name: Upload coverage report
uses: codecov/codecov-action@v1.0.14
- name: Upload Coverage Report
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
files: ./coverage.xml
flags: unittests
fail_ci_if_error: true

- name: Execute Static Code analysis
run: composer analyse
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,39 @@
[![Test](https://github.com/ComplexHeart/php-criteria/actions/workflows/test.yml/badge.svg)](https://github.com/ComplexHeart/php-criteria/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/ComplexHeart/php-criteria/branch/master/graph/badge.svg?token=T86pvAqfl6)](https://codecov.io/gh/ComplexHeart/php-criteria)

Small implementation of a filter criteria pattern. Compose several filters using fluent interface.
Small implementation of a filter criteria pattern in PHP for Complex Heart SDK. Compose several filters using fluent
interface.

##Installation

Just install the package from Packagist using composer:

```bash
composer require complexheart/php-criteria
```

## Usage

Just import the class:

```php
namespace ComplexHeart\Test\Domain\Criteria;

$criteria = Criteria::createDefault()
->addFilterEqual('name', 'Vincent')
->addFilterNotEqual('surname', 'winnfield')
->addFilterGreaterThan('money', '10000')
->addFilterGreaterOrEqualThan('age', '35')
->addFilterLessThan('cars', '2')
->addFilterLessOrEqualThan('houses', '2')
->addFilterLike('favoriteMeal', 'pork')
->addFilterIn('boss', ['marcellus', 'mia'])
->addFilterNotIn('hates', ['ringo', 'yolanda'])
->withOrder(Order::createDescBy('name'))
->withOrderBy('surname')
->withOrderType(Order::TYPE_ASC)
->withPageLimit(10)
->withPageOffset(5)

$customers = $customerRepository->match($criteria);
```
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "complex-heart/criteria",
"description": "Implementation of Criteria patterns for Complex Heart SDK.",
"description": "Small implementation of a filter criteria pattern in PHP for Complex Heart SDK. Compose several filters using fluent interface.",
"type": "library",
"license": "MIT",
"license": "Apache-2.0",
"authors": [
{
"name": "Unay Santisteban",
Expand All @@ -11,7 +11,7 @@
],
"minimum-stability": "stable",
"require": {
"php": "^7.4|^8.0",
"php": "^7.4|^8.0|^8.1",
"ext-json": "*",
"complex-heart/domain-model": "dev-develop"
},
Expand All @@ -32,5 +32,10 @@
"scripts": {
"test": "vendor/bin/pest --configuration=phpunit.xml --coverage-clover=coverage.xml",
"analyse": "vendor/bin/phpstan analyse src --no-progress --level=5"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true
}
}
}
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</include>
</coverage>
Expand Down