Skip to content

Commit 10cb361

Browse files
committed
Initial commit.
0 parents  commit 10cb361

29 files changed

+1137
-0
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
charset = utf-8
6+
max_line_length = 80
7+
indent_style = space
8+
indent_size = 4
9+
insert_final_newline = true

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/composer.lock
2+
/vendor
3+
/build
4+
/.php_cs.cache
5+
/example/
6+
/.idea/
7+
/test.php

.php_cs.dist

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude('build')
5+
->in(__DIR__);
6+
7+
return PhpCsFixer\Config::create()
8+
->setRiskyAllowed(true)
9+
->setRules([
10+
'@PSR2' => TRUE,
11+
'array_syntax' => ['syntax' => 'short'],
12+
'blank_line_after_opening_tag' => TRUE,
13+
'blank_line_before_statement' => [
14+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
15+
],
16+
'class_attributes_separation' => TRUE,
17+
'class_definition' => [
18+
'single_line' => TRUE,
19+
],
20+
'declare_equal_normalize' => [
21+
'space' => 'single',
22+
],
23+
'include' => TRUE,
24+
'is_null' => TRUE,
25+
'linebreak_after_opening_tag' => TRUE,
26+
'logical_operators' => TRUE,
27+
'lowercase_cast' => TRUE,
28+
'lowercase_constants' => FALSE,
29+
'lowercase_static_reference' => TRUE,
30+
'magic_method_casing' => TRUE,
31+
'native_function_invocation' => TRUE,
32+
'no_blank_lines_after_class_opening' => TRUE,
33+
'no_blank_lines_after_phpdoc' => FALSE,
34+
'no_closing_tag' => TRUE,
35+
'no_empty_comment' => TRUE,
36+
'no_empty_phpdoc' => TRUE,
37+
'no_empty_statement' => TRUE,
38+
'no_extra_blank_lines' => [
39+
'tokens' => [
40+
'extra',
41+
'curly_brace_block',
42+
'parenthesis_brace_block',
43+
'square_brace_block',
44+
'return',
45+
'throw',
46+
'use',
47+
'use_trait',
48+
],
49+
],
50+
'no_trailing_whitespace_in_comment' => TRUE,
51+
'no_unneeded_control_parentheses' => [
52+
'statements' => [
53+
'break',
54+
'clone',
55+
'continue',
56+
'echo_print',
57+
'return',
58+
'switch_case',
59+
'yield',
60+
]
61+
],
62+
'no_unused_imports' => TRUE,
63+
'single_blank_line_at_eof' => TRUE,
64+
'single_quote' => TRUE,
65+
'strict_comparison' => FALSE,
66+
'strict_param' => true,
67+
'trailing_comma_in_multiline_array' => TRUE,
68+
'yoda_style' => TRUE,
69+
])
70+
->setFinder($finder);

.scrutinizer.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
build: false
2+
3+
filter:
4+
paths:
5+
- 'src/*'
6+
7+
tools:
8+
external_code_coverage:
9+
timeout: 600
10+
php_code_sniffer:
11+
config:
12+
standard: PSR2
13+
sensiolabs_security_checker: true
14+
php_loc: true
15+
php_pdepend: true
16+
php_sim: true
17+
php_changetracking: true

.travis.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
language: php
2+
3+
git:
4+
depth: 1
5+
6+
cache:
7+
directories:
8+
- "$HOME/.cache/composer"
9+
- "$HOME/.composer/cache"
10+
11+
php:
12+
- 7.1
13+
- 7.2
14+
15+
install:
16+
- composer install
17+
18+
script:
19+
- composer grumphp
20+
21+
after_success:
22+
- phpenv config-rm xdebug.ini
23+
- composer scrutinizer
24+
- composer apigen
25+
26+
deploy:
27+
local-dir: build/docs
28+
provider: pages
29+
skip-cleanup: true
30+
github-token: $GITHUB_TOKEN
31+
keep-history: true
32+
on:
33+
branch: master

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Pol Dellaiera
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.

README.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[![Latest Stable Version](https://poser.pugx.org/drupol/phptree/v/stable)](https://packagist.org/packages/drupol/phptree)
2+
[![Total Downloads](https://poser.pugx.org/drupol/phptree/downloads)](https://packagist.org/packages/drupol/phptree)
3+
[![Build Status](https://travis-ci.org/drupol/phptree.svg?branch=master)](https://travis-ci.org/drupol/phptree)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/drupol/phptree/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/drupol/phptree/?branch=master)
5+
[![Code Coverage](https://scrutinizer-ci.com/g/drupol/phptree/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/drupol/phptree/?branch=master)
6+
[![Mutation testing badge](https://badge.stryker-mutator.io/github.com/drupol/phptree/master)](https://stryker-mutator.github.io)
7+
[![License](https://poser.pugx.org/drupol/phptree/license)](https://packagist.org/packages/drupol/phptree)
8+
9+
# PhpTree
10+
11+
## Description
12+
13+
A PHP implementation of tree data structure.
14+
15+
## Documentation
16+
17+
API documentation is automatically generated with [APIGen](https://github.com/ApiGen/ApiGen) and available at [this address](https://not-a-number.io/phptree/).
18+
19+
## Requirements
20+
21+
* PHP >= 7.1
22+
23+
## Installation
24+
25+
```composer require drupol/phptree```
26+
27+
## Usage
28+
29+
The object has to be used just like a regular array.
30+
31+
```php
32+
$tree = new drupol\phptree\Merkle();
33+
34+
$tree[] = 'hello';
35+
$tree[] = 'world';
36+
37+
$tree->hash(); // this returns: b9187808075710ab9c447c6ff6fd2aeb6c4bc10cf752e849102b87c0ecf97824
38+
39+
$tree['key'] = 'value';
40+
41+
$tree['key']; // this returns: 'value';
42+
```
43+
44+
## Code quality, tests and benchmarks
45+
46+
Every time changes are introduced into the library, [Travis CI](https://travis-ci.org/drupol/htmltag/builds) run the tests and the benchmarks.
47+
48+
The library has tests written with [PHPSpec](http://www.phpspec.net/).
49+
Feel free to check them out in the `spec` directory. Run `composer phpspec` to trigger the tests.
50+
51+
Before each commit some inspections are executed with [GrumPHP](https://github.com/phpro/grumphp), run `./vendor/bin/grumphp run` to check manually.
52+
53+
[PHPBench](https://github.com/phpbench/phpbench) is used to benchmark the library, to run the benchmarks: `composer bench`
54+
55+
[PHPInfection](https://github.com/infection/infection) is used to ensure that your code is properly tested, run `composer infection` to test your code.
56+
57+
## Contributing
58+
59+
Feel free to contribute to this library by sending Github pull requests. I'm quite reactive :-)

apigen.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
visibility_levels: [public, protected, private]
3+
annotation_groups: [todo, deprecated]
4+
title: "PhpTree API documentation"
5+
base_url: "https://not-a-number.io/phptree"
6+
overwrite: false

composer.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "drupol/phptree",
3+
"type": "library",
4+
"description": "An implementation of tree data structure",
5+
"keywords": ["tree", "php"],
6+
"license": "MIT",
7+
"prefer-stable": true,
8+
"minimum-stability": "dev",
9+
"authors": [
10+
{
11+
"name": "Pol Dellaiera",
12+
"email": "[email protected]"
13+
}
14+
],
15+
"require": {
16+
"php": ">=7.1"
17+
},
18+
"require-dev":{
19+
"apigen/apigen": "dev-master",
20+
"drupol/phpspec-annotation": "^1.0",
21+
"friendsofphp/php-cs-fixer": "^2.13",
22+
"infection/infection": "^0.11.2",
23+
"jakub-onderka/php-parallel-lint": "^1.0",
24+
"leanphp/phpspec-code-coverage": "^4",
25+
"maglnet/composer-require-checker": "^1.1",
26+
"monolog/monolog": "^1.0",
27+
"php-http/guzzle6-adapter": "^1.1",
28+
"phpbench/phpbench": "dev-master",
29+
"phpmd/phpmd": "^2.6",
30+
"phpro/grumphp": "^0.14.0",
31+
"phpspec/phpspec": "^4",
32+
"phpstan/phpstan": "^0.10",
33+
"roave/better-reflection": "dev-master",
34+
"roave/security-advisories": "dev-master",
35+
"scrutinizer/ocular": "^1.3",
36+
"sebastian/phpcpd": "^4.0",
37+
"sensiolabs/security-checker": "^4.1",
38+
"squizlabs/php_codesniffer": "^3"
39+
},
40+
"autoload": {
41+
"psr-4": {
42+
"drupol\\phptree\\": "src/"
43+
}
44+
},
45+
"autoload-dev": {
46+
"psr-4": {
47+
"drupol\\phptree\\tests\\": "spec/src/"
48+
}
49+
},
50+
"config": {
51+
"sort-packages": true
52+
},
53+
"scripts": {
54+
"apigen": "./vendor/bin/apigen generate src --destination build/docs",
55+
"phpspec": "./vendor/bin/phpspec run",
56+
"grumphp": "./vendor/bin/grumphp run",
57+
"phpcs": "./vendor/bin/phpcs --ignore=vendor .",
58+
"phpcbf": "./vendor/bin/phpcbf --ignore=vendor .",
59+
"infection": "./vendor/bin/infection run -j 10",
60+
"scrutinizer": "./vendor/bin/ocular code-coverage:upload --format=php-clover build/logs/clover.xml",
61+
"bench": "./vendor/bin/phpbench run --report=aggregate --store --precision=3"
62+
}
63+
}

grumphp.yml.dist

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
parameters:
2+
git_dir: .
3+
bin_dir: vendor/bin
4+
tasks:
5+
phplint: ~
6+
composer: ~
7+
phpcpd:
8+
directory: './src'
9+
phpstan:
10+
autoload_file: ~
11+
configuration: ~
12+
level: 7
13+
force_patterns: []
14+
ignore_patterns: ['/spec/', '/benchmarks/']
15+
triggered_by: ['php']
16+
phpcsfixer2: ~
17+
phpcs:
18+
standard: PSR2
19+
ignore_patterns:
20+
- vendor/
21+
- spec/
22+
triggered_by:
23+
- php
24+
phpspec:
25+
format: pretty
26+
stop_on_failure: true
27+
verbose: true
28+
securitychecker:
29+
lockfile: ./composer.lock
30+
format: ~
31+
end_point: ~
32+
timeout: ~
33+
run_always: false
34+
composer_require_checker:
35+
composer_file: 'composer.json'
36+
config_file: ~
37+
ignore_parse_errors: false
38+
triggered_by: ['composer.json', 'composer.lock', '*.php']
39+
infection:
40+
min_msi: 90
41+
min_covered_msi: 90

infection.json.dist

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"timeout": 10,
3+
"source": {
4+
"directories": [
5+
"src"
6+
]
7+
},
8+
"logs": {
9+
"text": "build/infection.log",
10+
"summary": "build/summary.log",
11+
"debug": "build/debug.log",
12+
"perMutator": "build/per-mutator.md",
13+
"badge": {
14+
"branch": "master"
15+
}
16+
},
17+
"testFramework":"phpspec",
18+
"tmpDir": "build"
19+
}

phpbench.json.dist

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"bootstrap": "vendor/autoload.php",
3+
"path": "benchmarks",
4+
"xml_storage_path": "build/benchmarks",
5+
"progress": "verbose",
6+
"extensions": [
7+
"PhpBench\\Extensions\\XDebug\\XDebugExtension"
8+
]
9+
}

phpspec.yml.dist

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
formatter.name: pretty
2+
extensions:
3+
drupol\PhpspecAnnotation\PhpspecAnnotation: ~
4+
LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension:
5+
format:
6+
- html
7+
- clover
8+
- php
9+
- text
10+
output:
11+
html: build/coverage
12+
clover: build/logs/clover.xml
13+
php: build/coverage.php

0 commit comments

Comments
 (0)