Download the PHP package skyree/document-hash-indexer without Composer
On this page you can find all versions of the php package skyree/document-hash-indexer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download skyree/document-hash-indexer
More information about skyree/document-hash-indexer
Files in skyree/document-hash-indexer
Package document-hash-indexer
Short Description Index csv or json documents as key-hash pairs in a yaml file
License MIT
Informations about the package document-hash-indexer
document-hash-indexer
This library allows you to generate an index of hashed values from a csv file or a list of json strings.
The result is a yaml file that can be easily used for quick diffs in order to spot changes, additions and deletions.
Pre-requisite
- php 7.1
- ext-json
Installation
Run composer require skyree/document-hash-indexer
from your project.
Getting started
All it takes is to instantiate a HashIndexer
and run the hash
method with the desired key.
Example
with file.json
containing the following
will result in
Important note: As mentioned in the description, for json documents, the expected input is list of json strings, not a properly formatted json object.
Important note 2: Make sure your input document has a unique key (a csv column whose values are all different or a json node whose value differs for each line), otherwise the generated yaml will be invalid as duplicates are forbidden.
Parsers
This library comes with 2 parsers:
ParserJson
ParserCsv
You can create and use your own parsers by implementing ParserInterface
ErrorHandlers
These handlers are used to provide a behavior when a key is not found on a line; This library comes with 2 handlers:
LazyErrorHandler
which basically ignores the errorThresholdErrorHandler
which allows up to n errors before interrupting
You can create and use your own handlers by implementing ErrorHandlerInterface
Integration with Symfony
This library can easily be defined as one or multiple services