alcamo / rdf-literal-serializer
(De)serialization of RDF literals
Package info
github.com/rv1971/alcamo-rdf-literal-serializer
pkg:composer/alcamo/rdf-literal-serializer
Requires
- php: 7.3 - 8.5
- alcamo/input-stream: ^0.4
- alcamo/rdf-literal-workbench: ^0.1
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: 3.*
This package is auto-updated.
Last update: 2026-07-10 18:26:07 UTC
README
namespace alcamo\rdf_literal_serializer;
use alcamo\rdf_literal\NonNegativeIntegerLiteral;
include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';
$serializer = AbstractSerializer::createFromProps(
[
'class' => NonNegativeIntegerSerializer::class,
'encoding' => 'EBCDIC',
'lengthRange' => [ 6, null ]
]
);
$literal1 = new NonNegativeIntegerLiteral(123);
$serialization = $serializer->serialize($literal1);
echo "Hexdump of EBCDIC: " . bin2hex($serialization) . PHP_EOL;
$literal2 = $serializer->deserialize($serialization);
echo "Deserialized to: $literal2" . PHP_EOL;
This example is contained in this package as a file in the bin
directory. It will output
Hexdump of EBCDIC: f0f0f0f1f2f3
Deserialized to: 123
The purpose of this package is to provide configurable (de)serialization of RDF literal objects (see alcamo/rdf-literal). Most serialization methods are rather trivial as such; the added value is the fact that the serialization parameters are completely configurable. As in the above example, in most cases at least the following are configurable:
- The serializer class - the right class depends on the dataype of the literal.
- The encoding.
- The length of the output.
See the doxygen documentation for details.