Skip to content
This repository was archived by the owner on Jan 12, 2020. It is now read-only.

Commit be406e8

Browse files
committed
Init
1 parent 0283fd7 commit be406e8

File tree

14 files changed

+400
-6
lines changed

14 files changed

+400
-6
lines changed

.gitignore

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
composer.phar
2-
/vendor/
3-
4-
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
5-
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
6-
# composer.lock
1+
vendor
2+
build
3+
#A library must not provide a composer.lock file
4+
composer.lock

.scrutinizer.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
build_failure_conditions:
2+
- 'project.metric_change("scrutinizer.quality", < -0.30)'
3+
- 'elements.rating(<= D).exists' # No classes/methods with a rating of D or worse
4+
- 'issues.severity(>= MAJOR).exists' # New major or higher severity issues
5+
- 'project.metric("scrutinizer.quality", < 9)' # Code Quality Rating drops below 9
6+
- 'project.metric("scrutinizer.test_coverage", < 1)' # Code Coverage must alway be 100%
7+
- 'patches.label("Doc Comments").exists' # No doc comments patches allowed
8+
- 'patches.label("Spacing").exists' # No spacing patches allowed
9+
- 'patches.label("Bug").exists' # No bug patches allowed
10+
- 'issues.label("coding-style").exists' # No coding style issues allowed
11+
build:
12+
dependencies:
13+
before:
14+
- composer global require hirak/prestissimo
15+
override:
16+
- make build
17+
tests:
18+
stop_on_failure: true
19+
override:
20+
- php-scrutinizer-run
21+
-
22+
command: make codestyle
23+
analysis:
24+
file: 'build/reports/cs-data'
25+
format: 'php-cs-checkstyle'
26+
-
27+
command: make coverage
28+
idle_timeout: 1200
29+
coverage:
30+
file: 'build/coverage/clover.xml'
31+
format: 'php-clover'
32+
cache:
33+
directories:
34+
- ~/.composer
35+
- vendor
36+
37+
environment:
38+
variables:
39+
CI: 'true'
40+
TEST_OUTPUT_STYLE: 'pretty'
41+
COVERAGE_OUTPUT_STYLE: 'clover'
42+
COVERAGE_CLOVER_FILE_PATH: 'build/coverage/clover.xml'
43+
PHPCS_REPORT_STYLE: 'checkstyle'
44+
PHPCS_REPORT_FILE: 'build/reports/cs-data'
45+
COMPOSER_OPTIONS: '--optimize-autoloader'
46+
php:
47+
version: "7.1"
48+
timezone: UTC
49+
postgresql: false
50+
redis: false
51+
filter:
52+
paths:
53+
- src/*
54+
checks:
55+
php:
56+
code_rating: true
57+
duplication: true
58+
no_debug_code: true
59+
check_method_contracts:
60+
verify_interface_like_constraints: true
61+
verify_documented_constraints: true
62+
verify_parent_constraints: true
63+
simplify_boolean_return: true
64+
return_doc_comments: true
65+
return_doc_comment_if_not_inferrable: true
66+
remove_extra_empty_lines: true
67+
properties_in_camelcaps: true
68+
phpunit_assertions: true
69+
parameters_in_camelcaps: true
70+
parameter_doc_comments: true
71+
param_doc_comment_if_not_inferrable: true
72+
overriding_parameter: true
73+
no_trailing_whitespace: true
74+
no_short_variable_names:
75+
minimum: '3'
76+
no_short_method_names:
77+
minimum: '3'
78+
no_long_variable_names:
79+
maximum: '20'
80+
no_goto: true
81+
naming_conventions:
82+
local_variable: '^[a-z][a-zA-Z0-9]*$'
83+
abstract_class_name: ^Abstract|Factory$
84+
utility_class_name: 'Utils?$'
85+
constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$'
86+
property_name: '^[a-z][a-zA-Z0-9]*$'
87+
method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$'
88+
parameter_name: '^[a-z][a-zA-Z0-9]*$'
89+
interface_name: '^[A-Z][a-zA-Z0-9]*Interface$'
90+
type_name: '^[A-Z][a-zA-Z0-9]*$'
91+
exception_name: '^[A-Z][a-zA-Z0-9]*Exception$'
92+
isser_method_name: '^(?:is|has|should|may|supports)'
93+
more_specific_types_in_doc_comments: true
94+
fix_doc_comments: false

.travis.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
language: php
2+
3+
php:
4+
- '7.0'
5+
- '7.1'
6+
- '7.2'
7+
8+
env:
9+
CI: 'true'
10+
TEST_OUTPUT_STYLE: 'pretty'
11+
PHPCS_REPORT_STYLE: 'full'
12+
COMPOSER_OPTIONS: '--optimize-autoloader'
13+
14+
sudo: false
15+
16+
matrix:
17+
fast_finish: true
18+
19+
install:
20+
- make build
21+
script:
22+
- make test-technical
23+
- make test-functional
24+
25+
cache:
26+
directories:
27+
- $HOME/.composer
28+
- vendor

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing
2+
3+
## Getting Started
4+
* Fork, then clone the repo:
5+
```bash
6+
git clone [email protected]:your-username/php-jsonrpc-server-sdk-psr11-resolver.git
7+
````
8+
9+
* Make sure everything goes well:
10+
```bash
11+
make build
12+
make test
13+
```
14+
15+
* Make your changes (Add/Update tests according to your changes).
16+
* Make sure tests are still green:
17+
```bash
18+
make test
19+
```
20+
21+
* To check code coverage, launch
22+
```bash
23+
make coverage
24+
```
25+
26+
* Push to your fork and [submit a pull request](https://github.com/yoanm/php-jsonrpc-server-sdk-psr11-resolver/compare/).
27+
* Wait for feedback or merge.
28+
29+
Some stuff that will increase your pull request's acceptance:
30+
* Write tests.
31+
* Follow PSR-2 coding style.
32+
* Write good commit messages.
33+
* Do not rebase or squash your commits when a review has been made.

Makefile

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
COLOR_ENABLED ?= true
2+
TEST_OUTPUT_STYLE ?= dot
3+
COVERAGE_OUTPUT_STYLE ?= html
4+
5+
## DIRECTORY AND FILE
6+
BUILD_DIRECTORY ?= build
7+
REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports
8+
COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage
9+
COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml
10+
11+
## Commands options
12+
### Composer
13+
#COMPOSER_OPTIONS=
14+
### Phpcs
15+
PHPCS_REPORT_STYLE ?= full
16+
#PHPCS_REPORT_FILE=
17+
#PHPCS_REPORT_FILE_OPTION=
18+
19+
# Enable/Disable color ouput
20+
ifeq ("${COLOR_ENABLED}","true")
21+
PHPUNIT_COLOR_OPTION ?= --colors=always
22+
BEHAT_COLOR_OPTION ?= --colors
23+
PHPCS_COLOR_OPTION ?= --colors
24+
COMPOSER_COLOR_OPTION ?= --ansi
25+
else
26+
PHPUNIT_COLOR_OPTION ?= --colors=never
27+
PHPCS_COLOR_OPTION ?= --no-colors
28+
BEHAT_COLOR_OPTION ?= --no-colors
29+
COMPOSER_COLOR_OPTION ?= --no-ansi
30+
endif
31+
32+
ifeq ("${TEST_OUTPUT_STYLE}","pretty")
33+
PHPUNIT_OUTPUT_STYLE_OPTION ?= --testdox
34+
BEHAT_OUTPUT_STYLE_OPTION ?= --format pretty
35+
else
36+
PHPUNIT_OUTPUT_STYLE_OPTION ?=
37+
BEHAT_OUTPUT_STYLE_OPTION ?= --format progress
38+
endif
39+
40+
ifeq ("${COVERAGE_OUTPUT_STYLE}","clover")
41+
PHPUNIT_COVERAGE_OPTION ?= --coverage-clover ${COVERAGE_CLOVER_FILE_PATH}
42+
else
43+
ifeq ("${COVERAGE_OUTPUT_STYLE}","html")
44+
PHPUNIT_COVERAGE_OPTION ?= --coverage-html ${COVERAGE_DIRECTORY}
45+
else
46+
PHPUNIT_COVERAGE_OPTION ?= --coverage-text
47+
endif
48+
endif
49+
50+
ifneq ("${PHPCS_REPORT_FILE}","")
51+
PHPCS_REPORT_FILE_OPTION ?= --report-file=${PHPCS_REPORT_FILE}
52+
endif
53+
54+
55+
## Project build (install and configure)
56+
build: install configure
57+
58+
## Project installation
59+
install:
60+
composer install ${COMPOSER_COLOR_OPTION} ${COMPOSER_OPTIONS} --prefer-dist --no-suggest --no-interaction
61+
62+
## project Configuration
63+
configure:
64+
65+
# Project tests
66+
test:
67+
make test-functional
68+
make test-technical
69+
make codestyle
70+
71+
test-technical:
72+
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite technical
73+
74+
test-functional:
75+
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} --testsuite functional
76+
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets
77+
78+
codestyle: create-reports-directory
79+
./vendor/bin/phpcs --standard=phpcs.xml.dist ${PHPCS_COLOR_OPTION} ${PHPCS_REPORT_FILE_OPTION} --report=${PHPCS_REPORT_STYLE}
80+
81+
coverage: create-coverage-directory
82+
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION}
83+
84+
85+
86+
# Internal commands
87+
create-coverage-directory:
88+
mkdir -p ${COVERAGE_DIRECTORY}
89+
90+
create-reports-directory:
91+
mkdir -p ${REPORTS_DIRECTORY}
92+
93+
94+
.PHONY: build install configure test test-technical test-functional codestyle coverage create-coverage-directory create-reports-directory
95+
.DEFAULT: build

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# PSR-11 method resolver for [`jsonrpc-server-sdk`](https://github.com/yoanm/php-jsonrpc-server-sdk)
2+
[![License](https://img.shields.io/github/license/yoanm/php-jsonrpc-server-sdk-psr11-resolver.svg)](https://github.com/yoanm/php-jsonrpc-server-sdk-psr11-resolver) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/php-jsonrpc-server-sdk-psr11-resolver.svg)](https://github.com/yoanm/php-jsonrpc-server-sdk-psr11-resolver) [![PHP Versions](https://img.shields.io/badge/php-7.0%20%2F%207.1%20%2F%207.2-8892BF.svg)](https://php.net/)
3+
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-server-sdk-psr11-resolver/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-server-sdk-psr11-resolver/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-server-sdk-psr11-resolver/badges/build.png?b=master)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-server-sdk-psr11-resolver/build-status/master) [![Code Coverage](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-server-sdk-psr11-resolver/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yoanm/php-jsonrpc-server-sdk-psr11-resolver/?branch=master)
5+
6+
[![Travis Build Status](https://img.shields.io/travis/yoanm/php-jsonrpc-server-sdk-psr11-resolver/master.svg?label=travis)](https://travis-ci.org/yoanm/php-jsonrpc-server-sdk-psr11-resolver) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/php-jsonrpc-server-sdk-psr11-resolver.svg)](https://travis-ci.org/yoanm/php-jsonrpc-server-sdk-psr11-resolver)
7+
8+
[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/jsonrpc-server-sdk-psr11-resolver.svg)](https://packagist.org/packages/yoanm/jsonrpc-server-sdk-psr11-resolver) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/jsonrpc-server-sdk-psr11-resolver.svg)](https://packagist.org/packages/yoanm/jsonrpc-server-sdk-psr11-resolver)
9+
10+
PSR-11 compliant method resolver for [`jsonrpc-server-sdk`](https://github.com/yoanm/php-jsonrpc-server-sdk)
11+
12+
## How to use
13+
14+
15+
## Contributing
16+
See [contributing note](./CONTRIBUTING.md)

behat.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
default:
2+
suites:
3+
default:
4+
contexts:
5+
- Tests\Functional\BehatContext\FeatureContext: ~

composer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "yoanm/jsonrpc-server-sdk-psr11-resolver",
3+
"description": "PSR-11 compliant method resolver for jsonrpc-server-sdk",
4+
"license": "GPL-3.0-only",
5+
"type": "library",
6+
"support": {
7+
"issues": "https://github.com/yoanm/php-jsonrpc-server-sdk-psr11-resolver/issues"
8+
},
9+
"authors": [
10+
{
11+
"name": "Yoanm",
12+
"email": "[email protected]",
13+
"role": "Developer"
14+
}
15+
],
16+
"autoload": {
17+
"psr-4": {
18+
"Yoanm\\JsonRpcServerPsr11Resolver\\App\\": "src/App",
19+
"Yoanm\\JsonRpcServerPsr11Resolver\\Domain\\": "src/Domain",
20+
"Yoanm\\JsonRpcServerPsr11Resolver\\Infra\\": "src/Infra"
21+
}
22+
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"Tests\\": "tests",
26+
"Tests\\Functional\\BehatContext\\": "features/bootstrap"
27+
}
28+
},
29+
"require": {
30+
"php": ">7.0",
31+
"yoanm/jsonrpc-server-sdk": "~v1.0",
32+
"psr/container": "^1.0"
33+
},
34+
"require-dev": {
35+
"behat/behat": "~3.0",
36+
"squizlabs/php_codesniffer": "3.*",
37+
"phpunit/phpunit": "^6.0"
38+
}
39+
}

features/bootstrap/FeatureContext.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
namespace Tests\Functional\BehatContext;
3+
4+
use Behat\Behat\Context\Context;
5+
use Behat\Gherkin\Node\PyStringNode;
6+
use PHPUnit\Framework\Assert;
7+
use Prophecy\Argument;
8+
use Tests\Functional\BehatContext\App\BehatMethodResolver;
9+
use Tests\Functional\BehatContext\App\FakeEndpointCreator;
10+
use Yoanm\JsonRpcServer\Domain\Model\MethodResolverInterface;
11+
use Yoanm\JsonRpcServer\Infra\Endpoint\JsonRpcEndpoint;
12+
13+
/**
14+
* Defines application features from the specific context.
15+
*/
16+
class FeatureContext implements Context
17+
{
18+
/**
19+
* Initializes context.
20+
*
21+
* Every scenario gets its own context instance.
22+
* You can also pass arbitrary arguments to the
23+
* context constructor through behat.yml.
24+
*/
25+
public function __construct()
26+
{
27+
}
28+
}

phpcs.xml.dist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Jsonrpc-server-sdk-psr11-resolver">
3+
<file>src</file>
4+
<file>tests</file>
5+
<file>features/bootstrap</file>
6+
7+
<arg value="p"/>
8+
<arg name="colors"/>
9+
<arg name="extensions" value="php"/>
10+
11+
<rule ref="PSR2"/>
12+
</ruleset>

0 commit comments

Comments
 (0)