Download the PHP package s1syphos/php-gesetze without Composer
On this page you can find all versions of the php package s1syphos/php-gesetze. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download s1syphos/php-gesetze
More information about s1syphos/php-gesetze
Files in s1syphos/php-gesetze
Package php-gesetze
Short Description Linking german legal norms, dependency-free & GDPR-friendly
License GPL-3.0
Homepage https://github.com/S1SYPHOS
Informations about the package php-gesetze
php-gesetze
Linking german legal norms, dependency-free & GDPR-friendly. php-gesetze
automatically transforms legal references into a
tags - batteries included.
There's also a Python port of this library, called py-gesetze
.
For API documentation (powered by phpDocumentor), see here.
Installation
It's available for Composer:
Getting started
Upon invoking the main class, you may specify your preferred provider (or 'driver'), like this:
It's also possible to specify selected of two or more drivers as array:
Note: This defaults to all available drivers, which is a good overall choice, simply because of the vast array of supported laws. Possible values are gesetze
, 'dejure'
, 'buzer'
and 'lexparency'
.
Out of the box, php-gesetze
cycles through all known drivers until a match is found.
Usage
From there, the following functions are available:
analyze(string $string): array
Analyzes a single legal norm:
validate(string $string): bool
Validates a single legal norm (across all selected providers:
Note: In the context of this library, being valid means linkable by at least one provider, as in to be found in their database.
roman2arabic(string $string): string
Converts roman numerals to arabic numerals:
extract(string $string): array
Extracts legal norms as array of strings:
gesetzify(string $string, callable $callback): string
Transforms legal references into HTML link tags:
Note: For more flexibility, you may use your own callback
method as second parameter of gesetzify
. Callbacks are being passed arrays representing matched legal norms. This way, you could highlight them using <strong>
tags instead of converting them into a
tags. Default: (private) method linkify
Example
Note: Caching the result (to avoid repeated lookups & save resources) is beyond the scope of this library and therefore totally up to you!
Configuration
There are several settings you may use in order to change the behavior of the library:
$object->drivers (array)
Associative array, holding all available drivers (already initialized), where the corresponding keys are 'gesetze'
, 'dejure'
, 'buzer'
& 'lexparency'
(default).
$object->pattern (string)
The regex responsible for detecting legal norms. For reference, it amounts to this:
Note: Well, more or less - for the latest revision, please refer to src/Traits/Regex.php
!
$object->attributes (array)
Other HTML attributes to be applied globally:
$object->title (false|string)
Controls title
attribute:
Option | Description |
---|---|
false |
No title attribute (default) |
'light' |
abbreviated law (eg 'GG') |
'normal' |
complete law (eg 'Grundgesetz') |
'full' |
official heading (eg 'Artikel 12') |
Credits
The regular expression used in this library is based on the jura_regex
regex package by Philipp Kiersch (originally written in Python).
Special Thanks
I'd like to thank everybody that's making free & open source software - you people are awesome. Also I'm always thankful for feedback and bug reports :)