-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
88b1633
commit 812f407
Showing
25 changed files
with
602 additions
and
1,823 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,36 @@ | ||
name: coding-style | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
jobs: | ||
coding-style: | ||
name: Coding style validation using Psalm and PHP_CodeSniffer | ||
runs-on: ubuntu-latest | ||
continue-on-error: false | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
php: | ||
- '7.4' | ||
- '8.3' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up php${{ matrix.php }} | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
|
||
- name: Install dependencies with Composer | ||
uses: ramsey/composer-install@v2 | ||
|
||
- name: Coding style validation using Psalm | ||
run: ./vendor/bin/psalm --config=./psalm.xml --show-info=true --shepherd | ||
|
||
- name: Coding style validation using PHP_CodeSniffer | ||
run: ./vendor/bin/phpcs --no-cache -v |
This file was deleted.
Oops, something went wrong.
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,55 @@ | ||
name: tests | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
jobs: | ||
tests: | ||
name: Tests with php${{ matrix.php }} | ||
runs-on: ubuntu-latest | ||
continue-on-error: false | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
php: | ||
- '7.4' | ||
- '8.1' | ||
- '8.2' | ||
- '8.3' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up php${{ matrix.php }} | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
coverage: xdebug | ||
|
||
- name: Install dependencies with Composer | ||
uses: ramsey/composer-install@v2 | ||
|
||
- name: Run tests with coverage results | ||
run: vendor/bin/phpunit --coverage-clover ./tests/_output/clover.xml | ||
|
||
- name: Upload coverage results to Coveralls | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COVERALLS_PARALLEL: true | ||
COVERALLS_FLAG_NAME: ${{ matrix.php }} | ||
run: | | ||
composer require php-coveralls/php-coveralls -n | ||
vendor/bin/php-coveralls --coverage_clover=./tests/_output/clover.xml -v --json_path=./tests/_output/coveralls-upload.json | ||
finish: | ||
name: Close parallel build | ||
needs: tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Close parallel build | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
parallel-finished: true | ||
carryforward: "8.0,8.1,8.2,8.3" |
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
.idea | ||
.env | ||
vendor | ||
docker/.env | ||
.phpunit.result.cache | ||
./vendor/ | ||
tests/_output | ||
!tests/_output/.gitkeep | ||
composer.lock |
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) 2024 Anton Petrenko | ||
|
||
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,66 @@ | ||
-include ./docker/.env | ||
|
||
.SILENT: | ||
.NOTPARALLEL: | ||
|
||
.DEFAULT_GOAL := inside | ||
|
||
init: | ||
cp ./docker/.env.example ./docker/.env && echo Created ./docker/.env | ||
.PHONY: init | ||
|
||
inside: | ||
docker exec -it ${CONTAINER_NAME} /bin/bash | ||
.PHONY: inside | ||
|
||
up80: | ||
docker-compose -f docker/docker-compose-php80.yml up -d | ||
.PHONY: up80 | ||
|
||
up81: | ||
docker-compose -f docker/docker-compose-php81.yml up -d | ||
.PHONY: up81 | ||
|
||
up82: | ||
docker-compose -f docker/docker-compose-php82.yml up -d | ||
.PHONY: up82 | ||
|
||
up83: | ||
docker-compose -f docker/docker-compose-php83.yml up -d | ||
.PHONY: up83 | ||
|
||
down: | ||
docker stop ${CONTAINER_NAME} && docker rm ${CONTAINER_NAME} | ||
.PHONY: down | ||
|
||
php-v: | ||
docker exec -it ${CONTAINER_NAME} php -v | ||
.PHONY: php-v | ||
|
||
v: | ||
docker exec -it ${CONTAINER_NAME} cat VERSION | ||
.PHONY: v | ||
|
||
test: | ||
docker exec -it ${CONTAINER_NAME} ./vendor/bin/phpunit | ||
.PHONY: test | ||
|
||
test-c: | ||
docker exec -it ${CONTAINER_NAME} ./vendor/bin/phpunit --coverage-text | ||
.PHONY: test-c | ||
|
||
test-ok: | ||
docker exec -it ${CONTAINER_NAME} ./vendor/bin/phpunit --group ok | ||
.PHONY: test-ok | ||
|
||
test+: | ||
docker exec -it ${CONTAINER_NAME} ./vendor/bin/phpunit --group + | ||
.PHONY: test+ | ||
|
||
psalm: | ||
docker exec -it ${CONTAINER_NAME} ./vendor/bin/psalm --show-info=true --no-cache | ||
.PHONY: psalm | ||
|
||
phpcs: | ||
docker exec -it ${CONTAINER_NAME} ./vendor/bin/phpcs -v | ||
.PHONY: phpcs |
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 |
---|---|---|
@@ -1,3 +1,145 @@ | ||
# key-normalizer | ||
|
||
[![PHP Composer](https://github.com/PetrenkoAnton/key-normalizer/actions/workflows/php.yml/badge.svg)](https://github.com/PetrenkoAnton/key-normalizer/actions/workflows/php.yml) | ||
[![PHP Version](https://img.shields.io/packagist/php-v/petrenkoanton/key-normalizer)](https://packagist.org/packages/petrenkoanton/key-normalizer) | ||
[![Latest Version on Packagist](https://img.shields.io/packagist/v/petrenkoanton/key-normalizer.svg)](https://packagist.org/packages/petrenkoanton/key-normalizer) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/petrenkoanton/key-normalizer.svg)](https://packagist.org/packages/petrenkoanton/key-normalizer) | ||
[![License](https://img.shields.io/packagist/l/petrenkoanton/key-normalizer)](https://packagist.org/packages/petrenkoanton/key-normalizer) | ||
|
||
[![PHP Composer](https://github.com/PetrenkoAnton/key-normalizer/actions/workflows/tests.yml/badge.svg)](https://github.com/PetrenkoAnton/key-normalizer/actions/workflows/tests.yml) | ||
[![Coverage Status](https://coveralls.io/repos/github/PetrenkoAnton/key-normalizer/badge.svg)](https://coveralls.io/github/PetrenkoAnton/key-normalizer) | ||
[![type-coverage](https://shepherd.dev/github/petrenkoanton/key-normalizer/coverage.svg)](https://shepherd.dev/github/petrenkoanton/key-normalizer) | ||
[![psalm-level](https://shepherd.dev/github/petrenkoanton/key-normalizer/level.svg)](https://shepherd.dev/github/petrenkoanton/key-normalizer) | ||
[![Build Status](https://github.com/petrenkoanton/key-normalizer/workflows/coding-style/badge.svg)](https://github.com/petrenkoanton/key-normalizer/actions) | ||
|
||
[Installation](#installation) | [Functionality](#functionality) | [Usage](#usage) | [For developers](#for-developers) | [License](#license) | [Related projects](#related-projects) | ||
|
||
## Installation | ||
|
||
### Requirements | ||
|
||
- php 8.0 or higher | ||
|
||
### Composer | ||
|
||
```bash | ||
composer require petrenkoanton/key-normalizer | ||
``` | ||
|
||
## Functionality | ||
|
||
### Public methods | ||
|
||
#### [KeyNormalizer](./src/KeyNormalizer.php) | ||
|
||
| Method | Exception | | ||
|:---------------------------------|:----------| | ||
| toCamelCase(string $key): string | - | | ||
| toSnakeCase(string $key): string | - | | ||
|
||
## Usage | ||
|
||
```php | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use KeyNormalizer\KeyNormalizer; | ||
|
||
KeyNormalizer::toCamelCase('test_test_test'); // testTestTest | ||
KeyNormalizer::toSnakeCase('testTestTest'); // test_test_test | ||
``` | ||
|
||
## For developers | ||
|
||
### Requirements | ||
|
||
Utils: | ||
- make | ||
- [docker-compose](https://docs.docker.com/compose/gettingstarted) | ||
|
||
### Setup | ||
|
||
#### Initialize | ||
|
||
Create `./docker/.env` | ||
```bash | ||
make init | ||
``` | ||
|
||
#### Build container with the different php version | ||
|
||
php 8.0 | ||
```bash | ||
make up80 | ||
``` | ||
|
||
php 8.1 | ||
```bash | ||
make up81 | ||
``` | ||
|
||
php 8.2 | ||
```bash | ||
make up82 | ||
``` | ||
|
||
php 8.3 | ||
```bash | ||
make up83 | ||
``` | ||
|
||
Also you need to run this command before build container with another php version. | ||
It will remove network and previously created container. | ||
```bash | ||
make down | ||
``` | ||
|
||
#### Other commands | ||
|
||
Go inside of the container | ||
```bash | ||
make inside | ||
``` | ||
|
||
Check php version | ||
```bash | ||
make php-v | ||
``` | ||
|
||
Check package version | ||
```bash | ||
make v | ||
``` | ||
|
||
### Run tests and linters | ||
|
||
Run [PHPUnit](https://github.com/sebastianbergmann/phpunit) tests with code coverage | ||
```bash | ||
make test-c | ||
``` | ||
|
||
Run [Psalm](https://github.com/vimeo/psalm) | ||
```bash | ||
make psalm | ||
``` | ||
|
||
Run [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) | ||
```bash | ||
make phpcs | ||
``` | ||
|
||
Or by all-in-one command from the inside of the container | ||
|
||
```bash | ||
composer check-all | ||
``` | ||
|
||
## License | ||
|
||
The [key-normalizer](https://github.com/PetrenkoAnton/key-normalizer) library is open-sourced software licensed under the | ||
[MIT license](./LICENSE). | ||
|
||
## Related projects | ||
|
||
- [PetrenkoAnton/php-collection](https://github.com/petrenkoanton/php-collection) | ||
- [PetrenkoAnton/php-dto](https://github.com/petrenkoanton/php-dto) |
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 @@ | ||
1.1.0 |
Oops, something went wrong.