Skip to content

Commit e295518

Browse files
authored
Documentation/Add installation and usage instructions. (#4)
1 parent 8e541c9 commit e295518

File tree

4 files changed

+54
-15
lines changed

4 files changed

+54
-15
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@ on:
77
jobs:
88
test:
99
runs-on: ubuntu-latest
10-
1110
strategy:
1211
matrix:
13-
php-version:
14-
- "7.4"
15-
- "8.0"
12+
php-version: [ 7.4, 8.0, 8.1 ]
1613

1714
steps:
1815
- name: Checkout source code
1916
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
2019

21-
- name: Install PHP
20+
- name: Set up PHP ${{ matrix.php-version }}
2221
uses: shivammathur/setup-php@v2
2322
with:
2423
php-version: ${{ matrix.php-version }}
@@ -38,16 +37,17 @@ jobs:
3837
- name: Install Dependencies
3938
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
4039

40+
- name: Execute Static Code analysis
41+
run: composer analyse
42+
4143
- name: Execute Unit, Integration and Acceptance Tests
4244
run: composer test
4345

44-
- name: Upload coverage report
45-
uses: codecov/codecov-action@v1.0.14
46+
- name: Upload Coverage Report
47+
uses: codecov/codecov-action@v2
4648
with:
4749
token: ${{ secrets.CODECOV_TOKEN }}
48-
file: ./coverage.xml
50+
files: ./coverage.xml
4951
flags: unittests
5052
fail_ci_if_error: true
5153

52-
- name: Execute Static Code analysis
53-
run: composer analyse

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,39 @@
33
[![Test](https://github.com/ComplexHeart/php-criteria/actions/workflows/test.yml/badge.svg)](https://github.com/ComplexHeart/php-criteria/actions/workflows/test.yml)
44
[![codecov](https://codecov.io/gh/ComplexHeart/php-criteria/branch/master/graph/badge.svg?token=T86pvAqfl6)](https://codecov.io/gh/ComplexHeart/php-criteria)
55

6-
Small implementation of a filter criteria pattern. Compose several filters using fluent interface.
6+
Small implementation of a filter criteria pattern in PHP for Complex Heart SDK. Compose several filters using fluent
7+
interface.
8+
9+
##Installation
10+
11+
Just install the package from Packagist using composer:
12+
13+
```bash
14+
composer require complexheart/php-criteria
15+
```
16+
17+
## Usage
18+
19+
Just import the class:
20+
21+
```php
22+
namespace ComplexHeart\Test\Domain\Criteria;
23+
24+
$criteria = Criteria::createDefault()
25+
->addFilterEqual('name', 'Vincent')
26+
->addFilterNotEqual('surname', 'winnfield')
27+
->addFilterGreaterThan('money', '10000')
28+
->addFilterGreaterOrEqualThan('age', '35')
29+
->addFilterLessThan('cars', '2')
30+
->addFilterLessOrEqualThan('houses', '2')
31+
->addFilterLike('favoriteMeal', 'pork')
32+
->addFilterIn('boss', ['marcellus', 'mia'])
33+
->addFilterNotIn('hates', ['ringo', 'yolanda'])
34+
->withOrder(Order::createDescBy('name'))
35+
->withOrderBy('surname')
36+
->withOrderType(Order::TYPE_ASC)
37+
->withPageLimit(10)
38+
->withPageOffset(5)
39+
40+
$customers = $customerRepository->match($criteria);
41+
```

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "complex-heart/criteria",
3-
"description": "Implementation of Criteria patterns for Complex Heart SDK.",
3+
"description": "Small implementation of a filter criteria pattern in PHP for Complex Heart SDK. Compose several filters using fluent interface.",
44
"type": "library",
5-
"license": "MIT",
5+
"license": "Apache-2.0",
66
"authors": [
77
{
88
"name": "Unay Santisteban",
@@ -11,7 +11,7 @@
1111
],
1212
"minimum-stability": "stable",
1313
"require": {
14-
"php": "^7.4|^8.0",
14+
"php": "^7.4|^8.0|^8.1",
1515
"ext-json": "*",
1616
"complex-heart/domain-model": "dev-develop"
1717
},
@@ -32,5 +32,10 @@
3232
"scripts": {
3333
"test": "vendor/bin/pest --configuration=phpunit.xml --coverage-clover=coverage.xml",
3434
"analyse": "vendor/bin/phpstan analyse src --no-progress --level=5"
35+
},
36+
"config": {
37+
"allow-plugins": {
38+
"pestphp/pest-plugin": true
39+
}
3540
}
3641
}

phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
</testsuites>
1212
<coverage processUncoveredFiles="true">
1313
<include>
14-
<directory suffix=".php">./app</directory>
1514
<directory suffix=".php">./src</directory>
1615
</include>
1716
</coverage>

0 commit comments

Comments
 (0)