From e117bc75e18c6cec0ee40d69839c25b2832e77c3 Mon Sep 17 00:00:00 2001 From: Unay Santisteban Date: Mon, 16 May 2022 11:12:21 +0200 Subject: [PATCH] Documentation/Add installation and usage instructions. --- .github/workflows/test.yml | 20 ++++++++++---------- README.md | 37 ++++++++++++++++++++++++++++++++++++- composer.json | 11 ++++++++--- phpunit.xml | 1 - 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 88726c2..26723ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} @@ -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 diff --git a/README.md b/README.md index e04a093..e0d83fe 100644 --- a/README.md +++ b/README.md @@ -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); +``` diff --git a/composer.json b/composer.json index 918c406..179805b 100644 --- a/composer.json +++ b/composer.json @@ -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", @@ -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" }, @@ -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 + } } } diff --git a/phpunit.xml b/phpunit.xml index 1d0c615..c0ab0d0 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -11,7 +11,6 @@ - ./app ./src