drupol/phpmerkle

A fast and dynamic Merkle tree implementation

Fund package maintenance!
drupol

2.2.1 2019-12-11 07:43 UTC

This package is auto-updated.

Last update: 2024-11-11 18:29:50 UTC


README

Latest Stable Version GitHub stars Total Downloads GitHub Workflow Status Scrutinizer code quality Code Coverage Mutation testing badge Read the Docs License Say Thanks! Donate!

PhpMerkle

A fast PHP implementation of the Merkle tree using simple arrays.

Documentation

TODO.

Requirements

  • PHP >= 7.1

Installation

composer require drupol/phpmerkle

Usage

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

<?php

declare(strict_types=1);

include './vendor/autoload.php';

$tree = new drupol\phpmerkle\Merkle();

$sentence = 'Science is made up of so many things that appear obvious after they are explained .';

foreach (explode(' ', $sentence) as $word) {
    $tree[] = $word;
}

echo $tree->hash(); // c689102cdf2a5b30c2e21fdad85e4bb401085227aff672a7240ceb3410ff1fb6

Code quality, tests and benchmarks

Every time changes are introduced into the library, Github run the tests and the benchmarks.

The library has tests written with PHPSpec. 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, run ./vendor/bin/grumphp run to check manually.

PHPBench is used to benchmark the library, to run the benchmarks: composer bench

PHPInfection 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 :-)