Skip to content

Commit

Permalink
Merge branch 'feature/third-release' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbero90 committed Sep 12, 2024
2 parents 0b15779 + d72a1d8 commit 4eae62c
Show file tree
Hide file tree
Showing 24 changed files with 322 additions and 354 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org
; More information at https://editorconfig.org

root = true

Expand Down
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github: cerbero90
ko_fi: cerbero90
77 changes: 23 additions & 54 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,20 @@
name: build

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
push:
pull_request:

jobs:
tests:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
fail-fast: false
matrix:
php: [7.0, 7.1, 7.2, 7.3, 7.4, 8.0]
laravel: [5.5.*, 5.6.*, 5.7.*, 5.8.*, 6.*, 7.*, 8.*]
php: [8.2, 8.3]
laravel: [11.*]
dependency-version: [prefer-lowest, prefer-stable]
os: [ubuntu-latest, windows-latest]
exclude:
- laravel: 5.5.*
php: 8.0
- laravel: 5.6.*
php: 7.0
- laravel: 5.6.*
php: 8.0
- laravel: 5.7.*
php: 7.0
- laravel: 5.7.*
php: 8.0
- laravel: 5.8.*
php: 7.0
- laravel: 5.8.*
php: 8.0
- laravel: 6.*
php: 7.0
- laravel: 6.*
php: 7.1
- laravel: 6.*
php: 8.0
dependency-version: prefer-lowest
- laravel: 7.*
php: 7.0
- laravel: 7.*
php: 7.1
- laravel: 8.*
php: 7.0
- laravel: 8.*
php: 7.1
- laravel: 8.*
php: 7.2
- os: windows-latest
php: 8.0
os: [ubuntu-latest]

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

Expand All @@ -68,11 +32,11 @@ jobs:

- name: Install dependencies
run: |
composer require "illuminate/contracts=${{ matrix.laravel }}" --no-interaction --no-update
composer require "illuminate/support=${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --verbose
run: vendor/bin/pest

coverage:
runs-on: ubuntu-latest
Expand All @@ -82,11 +46,13 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: xdebug
Expand All @@ -95,17 +61,16 @@ jobs:
run: composer update --prefer-stable --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
run: vendor/bin/pest --coverage-text --coverage-clover=coverage.clover

- name: Upload coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
style:
linting:
runs-on: ubuntu-latest

name: Coding style
name: Linting

steps:
- name: Checkout code
Expand All @@ -114,9 +79,13 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
tools: phpcs
php-version: 8.2
tools: composer:v2
coverage: none

- name: Execute check
run: phpcs --standard=psr12 src/ tests/
- name: Install dependencies
run: |
composer update --prefer-stable --prefer-dist --no-interaction
- name: Execute Duster
run: vendor/bin/duster lint -u tlint,phpcodesniffer,pint,phpstan -vvv
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ composer.lock
vendor
phpcs.xml
phpunit.xml
.phpunit.result.cache
.phpunit.cache
.phpunit.result.cache
.DS_Store
2 changes: 2 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
build:
environment:
php: 8.2
nodes:
analysis:
project_setup:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to `command-validator` will be documented in this file.

Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) principles.



Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)

Copyright (c) 2019 Andrea Marco Sartori <[email protected]>
Copyright (c) 2024 Andrea Marco Sartori <[email protected]>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
Expand Down
67 changes: 32 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,117 @@
# Command Validator
# Command Validator

[![Author][ico-author]][link-author]
[![PHP Version][ico-php]][link-php]
[![Laravel Version][ico-laravel]][link-laravel]
[![Build Status][ico-actions]][link-actions]
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
[![Quality Score][ico-code-quality]][link-code-quality]
[![PHPStan Level][ico-phpstan]][link-phpstan]
[![Latest Version][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![PSR-12][ico-psr12]][link-psr12]
[![PER][ico-per]][link-per]
[![Total Downloads][ico-downloads]][link-downloads]

[![SensioLabsInsight][ico-sensiolabs]][link-sensiolabs]
Laravel package to validate the input of console commands.

Laravel package to validate input in Artisan console commands.

## Install
## 📦 Install

Via Composer
Via Composer:

``` bash
$ composer require cerbero/command-validator
composer require cerbero/command-validator
```

## Usage
## 🔮 Usage

This package merely consists in the `ValidatesInput` trait that Artisan commands can use to define their own validation rules for arguments and options in the `rules()` method:
To validate the input of our console commands, we can use the `ValidatesInput` trait and define the validation rules for our arguments and options in the `rules()` method:

``` php
```php
use Illuminate\Console\Command;
use Cerbero\CommandValidator\ValidatesInput;

class SampleCommand extends Command
{
use ValidatesInput;

protected function rules()
protected function rules(): array
{
return [
'year' => 'integer|digits:4|min:2000',
'some_argument' => 'integer|digits:4|min:2000',
'some_option' => 'string|max:2',
];
}
}
```

The available rules are the same [validation rules][link-rules] provided by Laravel. If you need custom validation, please have a look at [how to define custom rules][link-custom-rules].
The available rules are the same [validation rules provided by Laravel](https://laravel.com/docs/validation#available-validation-rules). If we need custom validation, here is how we can [define custom rules in Laravel](https://laravel.com/docs/validation#custom-validation-rules).

Sometimes you may need to show custom messages or attributes for some validation errors. You can achieve that by overriding the methods `messages()` and `attributes()`:
Sometimes we may need to show custom messages or attributes for some validation errors. We can achieve that by overriding the methods `messages()` and `attributes()`:

``` php
protected function messages()
```php
protected function messages(): array
{
return [
'min' => 'The minimum allowed :attribute is :min'
'min' => 'The minimum allowed :attribute is :min',
];
}

protected function attributes()
protected function attributes(): array
{
return [
'year' => 'year of birth'
'year' => 'year of birth',
];
}
```

## Change log
## 📆 Change log

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Testing
## 🧪 Testing

``` bash
$ composer test
composer test
```

## Contributing
## 💞 Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.

## Security
## 🧯 Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Credits
## 🏅 Credits

- [Andrea Marco Sartori][link-author]
- [All Contributors][link-contributors]

## License
## ⚖️ License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

[ico-author]: https://img.shields.io/static/v1?label=author&message=cerbero90&color=50ABF1&logo=twitter&style=flat-square
[ico-php]: https://img.shields.io/packagist/php-v/cerbero/command-validator?color=%234F5B93&logo=php&style=flat-square
[ico-laravel]: https://img.shields.io/static/v1?label=laravel&message=%E2%89%A55.5&color=ff2d20&logo=laravel&style=flat-square
[ico-laravel]: https://img.shields.io/static/v1?label=laravel&message=%E2%89%A511&color=ff2d20&logo=laravel&style=flat-square
[ico-version]: https://img.shields.io/packagist/v/cerbero/command-validator.svg?label=version&style=flat-square
[ico-actions]: https://img.shields.io/github/workflow/status/cerbero90/command-validator/build?style=flat-square&logo=github
[ico-actions]: https://img.shields.io/github/actions/workflow/status/cerbero90/command-validator/build.yml?branch=master&style=flat-square&logo=github
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-psr12]: https://img.shields.io/static/v1?label=compliance&message=PSR-12&color=blue&style=flat-square
[ico-per]: https://img.shields.io/static/v1?label=compliance&message=PER&color=blue&style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/cerbero90/command-validator.svg?style=flat-square&logo=scrutinizer
[ico-code-quality]: https://img.shields.io/scrutinizer/g/cerbero90/command-validator.svg?style=flat-square&logo=scrutinizer
[ico-phpstan]: https://img.shields.io/badge/level-max-success?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGb0lEQVR42u1Xe1BUZRS/y4Kg8oiR3FCCBUySESZBRCiaBnmEsOzeSzsg+KxYYO9dEEftNRqZjx40FRZkTpqmOz5S2LsXlEZBciatkQnHDGYaGdFy1EpGMHl/p/PdFlt2rk5O+J9n5nA/vtf5ned3lnlISpRhafBlLRLHCtJGVrB/ZBDsaw2lUqzReGAC46DstTYfnSCGUjaaDvgxACo6j3vUenNdImeRXqdnWV5az5rrnzeZznj8J+E5Ftsclhf3s4J4CS/oRx5Bvon8ZU65FGYQxAwcf85a7CeRz+C41THejueydCZ7AAK34nwv3kHP/oUKdOL4K7258fF7Cud427O48RQeGkIGJ77N8fZqlrcfRP4d/x90WQfHXLeBt9dTrSlwl3V65ynWLM1SEA2qbNQckbe4Xmww10Hmy3shid0CMcmlEJtSDsl5VZBdfAgMvI3uuR+moJqN6LaxmpsOBeLCDmTifCB92RcQmbAUJvtqALc5sQr8p86gYBCcFdBq9wOin7NQax6ewlB6rqLZHf23FP10y3lj6uJtEBg2HxiVCtzd3SEwMBCio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nd8VJ6zlhsn06bEhwX4NyfCvuGEeRpTmh4mkG68yDpyuzB9EUcjU5awbAgncPlAeSdAQER0zCndzqVbeXC4qDsMpvGEYBXRnsDx4N3Auf1FCTjTIaVtY/QTmd0I8bBVm1kejEubUfO01vqImn3c49X7qpeqI9inIgtbpxK3YrKfIJCt+OeV2nfUVFR4ca4EkVENyA7gkYcMfB1R5MMmxZ7ez/2KF5SSN1yV+158UPsJT0ZBcI2bRLtIXGoYu5FerOUiJe1OfsL3XEWH43l2KS+iJF9+S4FpcNgsc+j8cT8H4o1bfPg/qkLt50uJ1RzdMsGg0UqwfEN114Pwb1CtWTGg+Y9U5ClK9x7xUWI7BI5VQVp0AVcQ3bZkQhmnEgdHhKyNSZe16crtBIlc7sIb6cRLft2PCgoKGjijBDtjrAQ7a3EdMsxzIRflAFIhPb6mHYmYwX+WBlPQgskhgVryyJCQyNyBLsBQdQ6fgsQhyt6MSOOsWZ7gbH8wETmgRKAijatNL8Ngm0xx4tLcsps0Wzx4al0jXlI40B/A3pa144MDtSgAAAAAElFTkSuQmCC
[ico-downloads]: https://img.shields.io/packagist/dt/cerbero/command-validator.svg?style=flat-square
[ico-sensiolabs]: https://insight.sensiolabs.com/projects/756ebffa-7aa3-464c-a7a4-3f09e37f897a/big.png

[link-author]: https://twitter.com/cerbero90
[link-php]: https://www.php.net
[link-laravel]: https://laravel.com
[link-packagist]: https://packagist.org/packages/cerbero/command-validator
[link-actions]: https://github.com/cerbero90/command-validator/actions?query=workflow%3Abuild
[link-psr12]: https://www.php-fig.org/psr/psr-12/
[link-per]: https://www.php-fig.org/per/coding-style/
[link-scrutinizer]: https://scrutinizer-ci.com/g/cerbero90/command-validator/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/cerbero90/command-validator
[link-downloads]: https://packagist.org/packages/cerbero/command-validator
[link-author]: https://github.com/cerbero90
[link-phpstan]: https://phpstan.org/
[link-contributors]: ../../contributors
[link-sensiolabs]: https://insight.sensiolabs.com/projects/756ebffa-7aa3-464c-a7a4-3f09e37f897a
[link-rules]: https://laravel.com/docs/validation#available-validation-rules
[link-custom-rules]: https://laravel.com/docs/validation#custom-validation-rules
37 changes: 20 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"name": "cerbero/command-validator",
"type": "library",
"description": "Validate Laravel console commands input.",
"description": "Laravel package to validate the input of console commands.",
"keywords": [
"cerbero",
"command-validator",
"laravel",
"console",
"commands",
"validator",
"validation"
"validation",
"command-line"
],
"homepage": "https://github.com/cerbero90/command-validator",
"license": "MIT",
Expand All @@ -19,15 +17,17 @@
"role": "Developer"
}],
"require": {
"php": "^7.0||^8.0",
"illuminate/contracts": ">=5.5",
"illuminate/support": ">=5.5",
"symfony/console": ">=3.3.7"
"php": "^8.2",
"illuminate/contracts": ">=11.0",
"symfony/console": "^7.0"
},
"require-dev": {
"orchestra/testbench": ">=3.5",
"phpunit/phpunit": ">=6.0",
"squizlabs/php_codesniffer": "^3.0"
"orchestra/testbench": ">=9.0",
"pestphp/pest": "^3.0",
"phpstan/phpstan": "^1.9",
"squizlabs/php_codesniffer": "^3.0",
"tightenco/duster": "^2.0",
"uma/ocular": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -40,16 +40,19 @@
}
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs src tests",
"fix-style": "phpcbf src tests"
"fix": "duster fix -u tlint,phpcodesniffer,pint",
"lint": "duster lint -u tlint,phpcodesniffer,pint,phpstan",
"test": "pest"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
}
}
Loading

0 comments on commit 4eae62c

Please sign in to comment.