Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 7, 2018
0 parents commit 10cb361
Show file tree
Hide file tree
Showing 29 changed files with 1,137 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
charset = utf-8
max_line_length = 80
indent_style = space
indent_size = 4
insert_final_newline = true
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/composer.lock
/vendor
/build
/.php_cs.cache
/example/
/.idea/
/test.php
70 changes: 70 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

$finder = PhpCsFixer\Finder::create()
->exclude('build')
->in(__DIR__);

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => TRUE,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => TRUE,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'class_attributes_separation' => TRUE,
'class_definition' => [
'single_line' => TRUE,
],
'declare_equal_normalize' => [
'space' => 'single',
],
'include' => TRUE,
'is_null' => TRUE,
'linebreak_after_opening_tag' => TRUE,
'logical_operators' => TRUE,
'lowercase_cast' => TRUE,
'lowercase_constants' => FALSE,
'lowercase_static_reference' => TRUE,
'magic_method_casing' => TRUE,
'native_function_invocation' => TRUE,
'no_blank_lines_after_class_opening' => TRUE,
'no_blank_lines_after_phpdoc' => FALSE,
'no_closing_tag' => TRUE,
'no_empty_comment' => TRUE,
'no_empty_phpdoc' => TRUE,
'no_empty_statement' => TRUE,
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'curly_brace_block',
'parenthesis_brace_block',
'square_brace_block',
'return',
'throw',
'use',
'use_trait',
],
],
'no_trailing_whitespace_in_comment' => TRUE,
'no_unneeded_control_parentheses' => [
'statements' => [
'break',
'clone',
'continue',
'echo_print',
'return',
'switch_case',
'yield',
]
],
'no_unused_imports' => TRUE,
'single_blank_line_at_eof' => TRUE,
'single_quote' => TRUE,
'strict_comparison' => FALSE,
'strict_param' => true,
'trailing_comma_in_multiline_array' => TRUE,
'yoda_style' => TRUE,
])
->setFinder($finder);
17 changes: 17 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
build: false

filter:
paths:
- 'src/*'

tools:
external_code_coverage:
timeout: 600
php_code_sniffer:
config:
standard: PSR2
sensiolabs_security_checker: true
php_loc: true
php_pdepend: true
php_sim: true
php_changetracking: true
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: php

git:
depth: 1

cache:
directories:
- "$HOME/.cache/composer"
- "$HOME/.composer/cache"

php:
- 7.1
- 7.2

install:
- composer install

script:
- composer grumphp

after_success:
- phpenv config-rm xdebug.ini
- composer scrutinizer
- composer apigen

deploy:
local-dir: build/docs
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
keep-history: true
on:
branch: master
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Pol Dellaiera

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.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[![Latest Stable Version](https://poser.pugx.org/drupol/phptree/v/stable)](https://packagist.org/packages/drupol/phptree)
[![Total Downloads](https://poser.pugx.org/drupol/phptree/downloads)](https://packagist.org/packages/drupol/phptree)
[![Build Status](https://travis-ci.org/drupol/phptree.svg?branch=master)](https://travis-ci.org/drupol/phptree)
[![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)
[![Code Coverage](https://scrutinizer-ci.com/g/drupol/phptree/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/drupol/phptree/?branch=master)
[![Mutation testing badge](https://badge.stryker-mutator.io/github.com/drupol/phptree/master)](https://stryker-mutator.github.io)
[![License](https://poser.pugx.org/drupol/phptree/license)](https://packagist.org/packages/drupol/phptree)

# PhpTree

## Description

A PHP implementation of tree data structure.

## Documentation

API documentation is automatically generated with [APIGen](https://github.com/ApiGen/ApiGen) and available at [this address](https://not-a-number.io/phptree/).

## Requirements

* PHP >= 7.1

## Installation

```composer require drupol/phptree```

## Usage

The object has to be used just like a regular array.

```php
$tree = new drupol\phptree\Merkle();

$tree[] = 'hello';
$tree[] = 'world';

$tree->hash(); // this returns: b9187808075710ab9c447c6ff6fd2aeb6c4bc10cf752e849102b87c0ecf97824

$tree['key'] = 'value';

$tree['key']; // this returns: 'value';
```

## Code quality, tests and benchmarks

Every time changes are introduced into the library, [Travis CI](https://travis-ci.org/drupol/htmltag/builds) run the tests and the benchmarks.

The library has tests written with [PHPSpec](http://www.phpspec.net/).
Feel free to check them out in the `spec` directory. Run `composer phpspec` to trigger the tests.

Before each commit some inspections are executed with [GrumPHP](https://github.com/phpro/grumphp), run `./vendor/bin/grumphp run` to check manually.

[PHPBench](https://github.com/phpbench/phpbench) is used to benchmark the library, to run the benchmarks: `composer bench`

[PHPInfection](https://github.com/infection/infection) is used to ensure that your code is properly tested, run `composer infection` to test your code.

## Contributing

Feel free to contribute to this library by sending Github pull requests. I'm quite reactive :-)
6 changes: 6 additions & 0 deletions apigen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
visibility_levels: [public, protected, private]
annotation_groups: [todo, deprecated]
title: "PhpTree API documentation"
base_url: "https://not-a-number.io/phptree"
overwrite: false
63 changes: 63 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "drupol/phptree",
"type": "library",
"description": "An implementation of tree data structure",
"keywords": ["tree", "php"],
"license": "MIT",
"prefer-stable": true,
"minimum-stability": "dev",
"authors": [
{
"name": "Pol Dellaiera",
"email": "pol.dellaiera@protonmail.com"
}
],
"require": {
"php": ">=7.1"
},
"require-dev":{
"apigen/apigen": "dev-master",
"drupol/phpspec-annotation": "^1.0",
"friendsofphp/php-cs-fixer": "^2.13",
"infection/infection": "^0.11.2",
"jakub-onderka/php-parallel-lint": "^1.0",
"leanphp/phpspec-code-coverage": "^4",
"maglnet/composer-require-checker": "^1.1",
"monolog/monolog": "^1.0",
"php-http/guzzle6-adapter": "^1.1",
"phpbench/phpbench": "dev-master",
"phpmd/phpmd": "^2.6",
"phpro/grumphp": "^0.14.0",
"phpspec/phpspec": "^4",
"phpstan/phpstan": "^0.10",
"roave/better-reflection": "dev-master",
"roave/security-advisories": "dev-master",
"scrutinizer/ocular": "^1.3",
"sebastian/phpcpd": "^4.0",
"sensiolabs/security-checker": "^4.1",
"squizlabs/php_codesniffer": "^3"
},
"autoload": {
"psr-4": {
"drupol\\phptree\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"drupol\\phptree\\tests\\": "spec/src/"
}
},
"config": {
"sort-packages": true
},
"scripts": {
"apigen": "./vendor/bin/apigen generate src --destination build/docs",
"phpspec": "./vendor/bin/phpspec run",
"grumphp": "./vendor/bin/grumphp run",
"phpcs": "./vendor/bin/phpcs --ignore=vendor .",
"phpcbf": "./vendor/bin/phpcbf --ignore=vendor .",
"infection": "./vendor/bin/infection run -j 10",
"scrutinizer": "./vendor/bin/ocular code-coverage:upload --format=php-clover build/logs/clover.xml",
"bench": "./vendor/bin/phpbench run --report=aggregate --store --precision=3"
}
}
41 changes: 41 additions & 0 deletions grumphp.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
parameters:
git_dir: .
bin_dir: vendor/bin
tasks:
phplint: ~
composer: ~
phpcpd:
directory: './src'
phpstan:
autoload_file: ~
configuration: ~
level: 7
force_patterns: []
ignore_patterns: ['/spec/', '/benchmarks/']
triggered_by: ['php']
phpcsfixer2: ~
phpcs:
standard: PSR2
ignore_patterns:
- vendor/
- spec/
triggered_by:
- php
phpspec:
format: pretty
stop_on_failure: true
verbose: true
securitychecker:
lockfile: ./composer.lock
format: ~
end_point: ~
timeout: ~
run_always: false
composer_require_checker:
composer_file: 'composer.json'
config_file: ~
ignore_parse_errors: false
triggered_by: ['composer.json', 'composer.lock', '*.php']
infection:
min_msi: 90
min_covered_msi: 90
19 changes: 19 additions & 0 deletions infection.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"timeout": 10,
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "build/infection.log",
"summary": "build/summary.log",
"debug": "build/debug.log",
"perMutator": "build/per-mutator.md",
"badge": {
"branch": "master"
}
},
"testFramework":"phpspec",
"tmpDir": "build"
}
9 changes: 9 additions & 0 deletions phpbench.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bootstrap": "vendor/autoload.php",
"path": "benchmarks",
"xml_storage_path": "build/benchmarks",
"progress": "verbose",
"extensions": [
"PhpBench\\Extensions\\XDebug\\XDebugExtension"
]
}
13 changes: 13 additions & 0 deletions phpspec.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
formatter.name: pretty
extensions:
drupol\PhpspecAnnotation\PhpspecAnnotation: ~
LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension:
format:
- html
- clover
- php
- text
output:
html: build/coverage
clover: build/logs/clover.xml
php: build/coverage.php

0 comments on commit 10cb361

Please sign in to comment.