Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrenkoAnton committed Jan 21, 2024
1 parent fec0426 commit 869568c
Show file tree
Hide file tree
Showing 61 changed files with 7,286 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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:
- '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 }}

- name: Install dependencies with Composer
uses: ramsey/composer-install@v2

- name: Coding style validation using Psalm
run: ./vendor/bin/psalm --show-info=true --shepherd

- name: Coding style validation using PHP_CodeSniffer
run: ./vendor/bin/phpcs --no-cache -v
54 changes: 54 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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:
- '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.1,8.2,8.3"
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/.idea
vendor
vendor
docker/.env
.phpunit.result.cache
/tests/output
!/tests/output/.gitkeep
66 changes: 66 additions & 0 deletions Makefile
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
104 changes: 103 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,103 @@
# php-dto
# php-dto

[![PHP Version](https://img.shields.io/packagist/php-v/petrenkoanton/php-dto)](https://packagist.org/packages/petrenkoanton/php-dto)
[![Latest Version on Packagist](https://img.shields.io/packagist/v/petrenkoanton/php-dto.svg)](https://packagist.org/packages/petrenkoanton/php-dto)
[![Total Downloads](https://img.shields.io/packagist/dt/petrenkoanton/php-dto.svg)](https://packagist.org/packages/petrenkoanton/php-dto)
[![License](https://img.shields.io/packagist/l/petrenkoanton/php-dto)](https://packagist.org/packages/petrenkoanton/php-dto)

[![PHP Composer](https://github.com/petrenkoanton/php-dto/actions/workflows/tests.yml/badge.svg)](https://github.com/petrenkoanton/php-dto/actions/workflows/tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/petrenkoanton/php-dto/badge.svg)](https://coveralls.io/github/petrenkoanton/php-dto)
[![type-coverage](https://shepherd.dev/github/petrenkoanton/php-dto/coverage.svg)](https://shepherd.dev/github/petrenkoanton/php-dto)
[![psalm-level](https://shepherd.dev/github/petrenkoanton/php-dto/level.svg)](https://shepherd.dev/github/petrenkoanton/php-dto)
[![Build Status](https://github.com/petrenkoanton/php-dto/workflows/coding-style/badge.svg)](https://github.com/petrenkoanton/php-dto/actions)

[Installation](#installation) | [Functionality](#functionality) | [Usage](#usage) | [For developers](#for-developers) | [License](#license)

## Installation

### Requirements

- PHP8.1 or higher

### Composer

```bash
composer require petrenkoanton/php-dto
```

## Functionality

### Public methods

| Method | Exception |
|:-------|:----------|
| | |

### Exceptions

| Exception | Parent | Message pattern | Code |
|:----------|:-------|:----------------|------|
| | | | |

## Usage

...

## For developers

### Requirements

Utils:
- make
- [docker-compose](https://docs.docker.com/compose/gettingstarted)

### Setup

Initialize:

```bash
make init # Create ./docker/.env
```

Build container with the different php version:

```bash
make up81 # php8.1
make up82 # php8.2
make up83 # php8.3
```

Also you need to run this command before build container with another php version:

```bash
make down # Remove network and container
```

Other commands:

```bash
make inside # Go inside of the container
make php-v # Check php version
make v # Check package version
```

### Run tests and linters

Using `make` util:

```bash
make test-c # Run tests with code coverage
make psalm # Run Psalm
make phpcs # Run PHP_CSFixer
```

Or from the inside of the container:

```bash
composer check-all
```

## License

The [php-dto](https://github.com/PetrenkoAnton/php-dto/) library is open-sourced software licensed under the
[MIT license](https://opensource.org/licenses/MIT).
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
54 changes: 54 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "petrenkoanton/php-dto",
"description": "Custom dto implementation",
"type": "library",
"keywords": ["dto", "structure"],
"minimum-stability": "stable",
"license": "MIT",
"authors": [
{
"name": "Anton Petrenko",
"email": "antptrnk@gmail.com",
"homepage": "https://github.com/petrenkoanton",
"role": "Developer"
}
],
"require": {
"php": "^8.1",
"petrenkoanton/php-collection": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"php-coveralls/php-coveralls": "^2.7",
"vimeo/psalm": "^5.16",
"psalm/plugin-phpunit": "^0.18.4",
"ramsey/coding-standard": "^2.1",
"squizlabs/php_codesniffer": "^3.8"
},
"autoload": {
"psr-4": {
"Dto\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
},
"scripts": {
"check-all": [
"composer install",
"@test",
"@psalm",
"@phpcs"
],
"test": "./vendor/bin/phpunit --coverage-text",
"psalm": "./vendor/bin/psalm",
"phpcs": "./vendor/bin/phpcs -v"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}

0 comments on commit 869568c

Please sign in to comment.