Skip to content

Commit db07011

Browse files
Initial commit
0 parents  commit db07011

21 files changed

+5259
-0
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.php]
14+
indent_style = space
15+
indent_size = 4
16+
charset = utf-8

.github/workflows/ci.yaml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
testsuite:
7+
name: Unittests
8+
runs-on: ubuntu-20.04
9+
10+
env:
11+
DB_HOST: 127.0.0.1
12+
DB_DATABASE: test
13+
DB_USER: test
14+
DB_ROOT_PASSWORD: changeme
15+
DB_PASSWORD: changeme
16+
REDIS_SCHEME: tcp
17+
REDIS_HOST: 127.0.0.1
18+
REDIS_PORT: 6379
19+
20+
services:
21+
mariadb:
22+
image: mariadb:latest
23+
ports:
24+
- 3306:3306
25+
env:
26+
DATABASE_HOST: 127.0.0.1
27+
MARIADB_DATABASE: test
28+
MARIADB_USER: test
29+
MARIADB_ROOT_PASSWORD: changeme
30+
MARIADB_PASSWORD: changeme
31+
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
32+
redis:
33+
image: redis
34+
options: >-
35+
--health-cmd "redis-cli ping"
36+
--health-interval 10s
37+
--health-timeout 5s
38+
--health-retries 5
39+
ports:
40+
- 6379:6379
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
php-version: ['8.2', '8.3']
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 1
51+
52+
- name: Setup PHP
53+
uses: shivammathur/setup-php@v2
54+
with:
55+
php-version: ${{ matrix.php-version }}
56+
extensions: json, fileinfo
57+
tools: pecl
58+
coverage: pcov
59+
60+
- name: Composer install
61+
run: |
62+
if [[ ${{ matrix.prefer-lowest == 'prefer-lowest' }} ]]; then
63+
composer update --prefer-lowest --prefer-stable
64+
else
65+
composer install
66+
fi
67+
68+
- name: Run PHPUnit
69+
run: |
70+
if [[ ${{ matrix.php-version }} == '8.2' ]]; then
71+
bin/phpunit --coverage-clover=coverage.xml
72+
else
73+
bin/phpunit
74+
fi
75+
- name: Code Coverage Report
76+
if: success() && matrix.php-version == '8.2'
77+
uses: codecov/codecov-action@v4
78+
79+
- name: Run Infection
80+
run: |
81+
if [[ ${{ matrix.php-version }} == '8.2' ]]; then
82+
bin/infection
83+
fi
84+
85+
cs-stan:
86+
name: Coding Standard & Static Analysis
87+
runs-on: ubuntu-20.04
88+
89+
steps:
90+
- uses: actions/checkout@v4
91+
with:
92+
fetch-depth: 1
93+
94+
- name: Setup PHP
95+
uses: shivammathur/setup-php@v2
96+
with:
97+
php-version: ${{ matrix.php-version }}
98+
extensions: json, fileinfo
99+
coverage: pcov
100+
tools: pecl
101+
102+
- name: Composer install
103+
run: composer update --prefer-lowest --prefer-stable
104+
105+
- name: Run phpcs
106+
run: bin/phpcs --version && bin/phpcs --report=source --standard=phpcs.xml
107+
108+
- name: Run phpstan
109+
run: bin/phpstan -V && bin/phpstan --error-format=github
110+
111+
- name: Run Infection
112+
run: bin/infection

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/bin
2+
/vendor
3+
/tools
4+
/tmp
5+
.idea
6+
.phpunit.cache
7+
.phpunit.result.cache
8+
infection.log
9+
*.drawio.bkp
10+
*.drawio.dtmp
11+
.env
12+
phpunit.xml

Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM php:8.3-cli
2+
3+
RUN pecl install redis-5.3.7 \
4+
&& pecl install xdebug-3.2.1 \
5+
&& docker-php-ext-enable pdo_mysql
6+
7+
# Install Composer globally
8+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Florian Krämer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.DEFAULT_GOAL := help
2+
3+
help:
4+
@echo "Available commands:"
5+
@echo " - run-tests: Run tests"
6+
@echo " - run-infection: Runs Infection mutation testing"
7+
@echo " - coverage-text: Runs coverage text"
8+
@echo " - coverage-html: Runs coverage html"
9+
@echo " - all: Runs CS-Fixer, CS-Checker, Static Analyser and Tests"
10+
@echo " - shell: Run shell"
11+
12+
run-tests:
13+
@echo "Running tests"
14+
docker compose run php composer test
15+
16+
run-infection:
17+
@echo "Running infection mutation testing"
18+
docker compose run php composer infection
19+
20+
coverage-text:
21+
@echo "Running coverage text"
22+
docker compose run php composer test-coverage
23+
24+
coverage-html:
25+
@echo "Running coverage text"
26+
docker compose run php composer test-coverage-html
27+
28+
all:
29+
@echo "Running CS-Fixer, CS-Checker, Static Analyser and Tests"
30+
docker compose run php composer all
31+
32+
benchmark:
33+
@echo "Running phpbench"
34+
docker compose run php composer benchmark
35+
36+
shell:
37+
@echo "Running shell"
38+
docker compose run --service-ports --entrypoint /bin/bash php

composer.json

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"name": "phauthentic/optional",
3+
"description": "PHP version of Javas Optional class, used to represent a container object which may or may not contain a non-null value.",
4+
"keywords": [
5+
"optional", "php", "oop", "library", "utility"
6+
],
7+
"type": "library",
8+
"require-dev": {
9+
"squizlabs/php_codesniffer": "^3.10",
10+
"phpmd/phpmd": "^2.15",
11+
"infection/infection": "^0.29.6",
12+
"phpunit/phpunit": "^11.2",
13+
"phpstan/phpstan": "^1.11"
14+
},
15+
"license": "MIT",
16+
"autoload": {
17+
"psr-4": {
18+
"Phauthentic\\Optional\\": "src/"
19+
}
20+
},
21+
"autoload-dev": {
22+
"psr-4": {
23+
"Phauthentic\\Optional\\Test\\": "tests/"
24+
}
25+
},
26+
"authors": [
27+
{
28+
"name": "Florian Krämer"
29+
}
30+
],
31+
"require": {
32+
"php": "^8.2"
33+
},
34+
"config": {
35+
"bin-dir": "bin",
36+
"allow-plugins": {
37+
"infection/extension-installer": true
38+
}
39+
},
40+
"scripts": {
41+
"test": [
42+
"phpunit"
43+
],
44+
"infection": [
45+
"infection"
46+
],
47+
"test-coverage": [
48+
"phpunit --coverage-text"
49+
],
50+
"test-coverage-html": [
51+
"phpunit --coverage-html tmp/coverage/"
52+
],
53+
"cscheck": [
54+
"phpcs src/ tests/ --standard=PSR12 -s"
55+
],
56+
"csfix": [
57+
"phpcbf src/ tests/ --standard=PSR12"
58+
],
59+
"analyze": [
60+
"phpstan analyse src/"
61+
],
62+
"phpmd": [
63+
"bin/phpmd ./src text cleancode,codesize,controversial,design"
64+
],
65+
"benchmark": [
66+
"bin/phpbench run tests/Benchmark/ --report=aggregate"
67+
],
68+
"all": [
69+
"@csfix",
70+
"@cscheck",
71+
"@analyze",
72+
"@test"
73+
]
74+
}
75+
}

0 commit comments

Comments
 (0)