Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bf70a3a
Showing
31 changed files
with
7,182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
###> defaults ### | ||
/.env.local | ||
/.env.local.php | ||
/.env.*.local | ||
/var/ | ||
/vendor/ | ||
###< defaults ### | ||
|
||
###> ide ### | ||
/.idea | ||
###< ide ### | ||
|
||
###> friendsofphp/php-cs-fixer ### | ||
/.php-cs-fixer.php | ||
/.php-cs-fixer.cache | ||
###< friendsofphp/php-cs-fixer ### | ||
|
||
###> phpunit ### | ||
/.phpunit.result.cache | ||
###< phpunit ### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
$finder = (new PhpCsFixer\Finder()) | ||
->in(__DIR__) | ||
->exclude('var') | ||
; | ||
|
||
return (new PhpCsFixer\Config()) | ||
->setRules([ | ||
'@PSR12' => true, | ||
]) | ||
->setFinder($finder) | ||
->setHideProgress(true) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||
|
||
## Releases | ||
|
||
### [0.1.0] - 2022-12-31 | ||
|
||
* Initial release | ||
* Add src | ||
* Add tests | ||
* PHP Coding Standards Fixer | ||
* PHPMND - PHP Magic Number Detector | ||
* PHPStan - PHP Static Analysis Tool | ||
* PHPUnit - The PHP Testing Framework | ||
* Rector - Instant Upgrades and Automated Refactoring | ||
* Add README.md | ||
* Add LICENSE.md | ||
|
||
## Add new version | ||
|
||
```bash | ||
# Checkout master branch | ||
$ git checkout main && git pull | ||
|
||
# Check current version | ||
$ vendor/bin/version-manager --current | ||
|
||
# Increase patch version | ||
$ vendor/bin/version-manager --patch | ||
|
||
# Change changelog | ||
$ vi CHANGELOG.md | ||
|
||
# Push new version | ||
$ git add CHANGELOG.md VERSION && git commit -m "Add version $(cat VERSION)" && git push | ||
|
||
# Tag and push new version | ||
$ git tag -a "$(cat VERSION)" -m "Version $(cat VERSION)" && git push origin "$(cat VERSION)" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Björn Hempel <bjoern@hempel.li> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# PHP Json Schema Validator | ||
|
||
[![Release](https://img.shields.io/github/v/release/ixnode/php-json-schema-validator)](https://github.com/ixnode/php-json-schema-validator/releases) | ||
[![PHP](https://img.shields.io/badge/PHP-^8.0-777bb3.svg?logo=php&logoColor=white&labelColor=555555&style=flat)](https://www.php.net/supported-versions.php) | ||
[![PHPStan](https://img.shields.io/badge/PHPStan-Level%20Max-brightgreen.svg?style=flat)](https://phpstan.org/user-guide/rule-levels) | ||
[![PHPCS](https://img.shields.io/badge/PHPCS-PSR12-brightgreen.svg?style=flat)](https://www.php-fig.org/psr/psr-12/) | ||
[![LICENSE](https://img.shields.io/github/license/ixnode/php-json-schema-validator)](https://github.com/ixnode/php-json-schema-validator/blob/master/LICENSE) | ||
|
||
> An easy-to-use PHP Json Schema Validator on top of [opis/json-schema](https://github.com/opis/json-schema). | ||
## Installation | ||
|
||
```bash | ||
composer require ixnode/php-json-schema-validator | ||
``` | ||
|
||
```bash | ||
vendor/bin/php-json-schema-validator -V | ||
``` | ||
|
||
```bash | ||
php-json-schema-validator 0.1.0 (12-31-2022 15:51:08) - Björn Hempel <bjoern@hempel.li> | ||
``` | ||
|
||
## Usage | ||
|
||
```php | ||
use Ixnode\PhpJsonSchemaValidator\Validator; | ||
``` | ||
|
||
```php | ||
$data = '[1, 2, 3]'; | ||
|
||
$schema = [ | ||
'type' => 'object' | ||
]; | ||
|
||
$validator = new Validator(new Json($data), new Json($schema)); | ||
|
||
$valid = $validator->validate(); | ||
``` | ||
|
||
## Development | ||
|
||
```bash | ||
git clone git@github.com:ixnode/php-json-schema-validator.git && cd php-json-schema-validator | ||
``` | ||
|
||
```bash | ||
composer install | ||
``` | ||
|
||
```bash | ||
composer test | ||
``` | ||
|
||
## License | ||
|
||
This tool is licensed under the MIT License - see the [LICENSE](/LICENSE) file for details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ------------ | ||
# This script prints the header for TEST-DB - Initialization | ||
# | ||
# @author Björn Hempel <bjoern@hempel.li> | ||
# @version 0.1.0 (2022-12-18) | ||
# ------------ | ||
|
||
HEADER="TEST-DB - Initialization" | ||
COMMAND="$1" | ||
DESCRIPTION="$2" | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
eval "$SCRIPT_DIR/global \"$HEADER\" \"$COMMAND\" \"$DESCRIPTION\" \"$DESCRIPTION\"" | ||
RETURN_CODE=$? | ||
|
||
exit $RETURN_CODE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ------------ | ||
# This script prints an error message | ||
# | ||
# @author Björn Hempel <bjoern@hempel.li> | ||
# @version 0.1.0 (2022-12-18) | ||
# ------------ | ||
|
||
HEADER="Error - At least one test is failed (-_-) " | ||
|
||
START_COLOR='\e[48;2;224;108;117m\e[38;2;9;16;22m' | ||
END_COLOR='\e[0m' | ||
|
||
printf "\n" | ||
printf "%b┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐%b\n" "$START_COLOR" "$END_COLOR" | ||
printf "%b│ │%b\n" "$START_COLOR" "$END_COLOR" | ||
printf "%b│ %-116s │%b\n" "$START_COLOR" ">>> $HEADER <<<" "$END_COLOR" | ||
printf "%b│ │%b\n" "$START_COLOR" "$END_COLOR" | ||
printf "%b└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘%b\n" "$START_COLOR" "$END_COLOR" | ||
printf "\n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ------------ | ||
# This script prints the base header for given string | ||
# | ||
# @author Björn Hempel <bjoern@hempel.li> | ||
# @version 0.1.0 (2022-12-18) | ||
# ------------ | ||
|
||
HEADER=$1 | ||
COMMAND="$2" | ||
DESCRIPTION="$3" | ||
|
||
[ "$DESCRIPTION" != "" ] && HEADER="$HEADER ($DESCRIPTION)" | ||
|
||
# ------------ | ||
# Checks if a given application exists | ||
# | ||
# @author Björn Hempel | ||
# @version 1.0 | ||
# ------------ | ||
function application_exists() | ||
{ | ||
`which $1 >/dev/null` | ||
} | ||
|
||
# ------------ | ||
# Returns the current time in milliseconds. | ||
# | ||
# @author Björn Hempel | ||
# @version 1.0 | ||
# ------------ | ||
function get_time() | ||
{ | ||
# Use mac gdate | ||
if application_exists 'gdate'; then | ||
echo $(gdate +%s%3N) | ||
return 0 | ||
fi | ||
|
||
# In bash 5.0 we do have $EPOCHREALTIME | ||
if [ ! -z ${EPOCHREALTIME} ]; then | ||
printf "%.3f" ${EPOCHREALTIME} | tr -d '.' | tr -d ',' | ||
return 0 | ||
fi | ||
|
||
# Last option to use date (this works not correctly on a mac). | ||
echo $(($(date +'%s * 1000 + %-N / 1000000'))) | ||
} | ||
|
||
START_COLOR='\e[48;2;97;175;239m\e[38;2;9;16;22m' | ||
END_COLOR='\e[0m' | ||
|
||
printf "\n" | ||
printf "%b┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐%b\n" "$START_COLOR" "$END_COLOR" | ||
printf "%b│ │%b\n" "$START_COLOR" "$END_COLOR" | ||
printf "%b│ %-116s │%b\n" "$START_COLOR" ">>> $HEADER <<<" "$END_COLOR" | ||
printf "%b│ │%b\n" "$START_COLOR" "$END_COLOR" | ||
printf "%b└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘%b\n" "$START_COLOR" "$END_COLOR" | ||
printf "\n" | ||
|
||
START_TIME=$(get_time) | ||
|
||
eval "$COMMAND" | ||
RETURN_CODE=$? | ||
|
||
END_TIME=$(get_time) | ||
|
||
ELAPSED=$((END_TIME-START_TIME)) | ||
|
||
printf "\n" | ||
printf " Time taken: %d ms\n" "$ELAPSED" | ||
printf "\n" | ||
printf "\n" | ||
|
||
exit $RETURN_CODE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ------------ | ||
# This script prints the rsm header | ||
# | ||
# @author Björn Hempel <bjoern@hempel.li> | ||
# @version 0.1.0 (2022-12-18) | ||
# ------------ | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
VERSION_PATH="$SCRIPT_DIR/../../VERSION" | ||
VERSION=$(cat $VERSION_PATH) | ||
|
||
HEADER1="PHPNamingConventions (PNC)" | ||
HEADER2="Version: $VERSION" | ||
HEADER3="Copyright (c) 2022 björn hempel <bjoern@hempel.li>" | ||
|
||
echo | ||
printf " ┌───┐ ┌───┐ ┌───┐ ┌───┐ " | ||
printf "$HEADER1" | ||
echo | ||
printf " │ I │ │ X │ │ N │ │ O │ " | ||
printf "$HEADER2" | ||
echo | ||
printf " └───┘ └───┘ └───┘ └───┘ " | ||
printf "$HEADER3" | ||
echo | ||
echo | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ------------ | ||
# This script prints the header for PHP Coding Standards Fixer | ||
# | ||
# @author Björn Hempel <bjoern@hempel.li> | ||
# @version 0.1.0 (2022-12-18) | ||
# ------------ | ||
|
||
HEADER="PHP Coding Standards Fixer" | ||
COMMAND="$1" | ||
DESCRIPTION="$2" | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
eval "$SCRIPT_DIR/global \"$HEADER\" \"$COMMAND\" \"$DESCRIPTION\"" | ||
RETURN_CODE=$? | ||
|
||
exit $RETURN_CODE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ------------ | ||
# This script prints the header for PHPMD - PHP Mess Detector | ||
# | ||
# @author Björn Hempel <bjoern@hempel.li> | ||
# @version 0.1.0 (2022-12-30) | ||
# ------------ | ||
|
||
HEADER="PHPMD - PHP Mess Detector" | ||
COMMAND="$1" | ||
DESCRIPTION="$2" | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
eval "$SCRIPT_DIR/global \"$HEADER\" \"$COMMAND\" \"$DESCRIPTION\"" | ||
RETURN_CODE=$? | ||
|
||
exit $RETURN_CODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
# ------------ | ||
# This script prints the header for PHPMND - PHP Magic Number Detector | ||
# | ||
# @author Björn Hempel <bjoern@hempel.li> | ||
# @version 0.1.0 (2022-12-18) | ||
# ------------ | ||
|
||
HEADER="PHPMND - PHP Magic Number Detector" | ||
COMMAND="$1" | ||
DESCRIPTION="$2" | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
eval "$SCRIPT_DIR/global \"$HEADER\" \"$COMMAND\" \"$DESCRIPTION\" \"$DESCRIPTION\"" | ||
RETURN_CODE=$? | ||
|
||
exit $RETURN_CODE | ||
|
Oops, something went wrong.