Germania KG · UuidServiceProvider
Pimple Service Provider for working with Ben Ramsey's ramsey/uuid package, (*1)
, (*2)
Installation with Composer
$ composer require germania-kg/uuidserviceprovider
Setup
<?php
use Germania\UuidServiceProvider\UuidServiceProvider;
// A. Use with Slim or Pimple
$app = new \Slim\App;
$dic = $app->getContainer();
$dic = new Pimple\Container;
// B. Register Service Provider.
$dic->register( new UuidServiceProvider );
Services
UUID.new
Factory: Returns a new version 4 (random) UUID object as Ramsey\Uuid\Uuid instance., (*3)
<?php
$uuid4 = $dic['UUID.new'];
UUID.new.hex
Returns the hex string representation of a UUID.new object., (*4)
<?php
$uuid4_hex = $dic['UUID.new.hex'];
UUID.Factory
Returns a callable that returns UUID object as Ramsey\Uuid\Uuid instance., (*5)
<?php
$factory = $dic['UUID.Factory'];
$uuid4 = $factory();
UUID.HexFactory
Returns a callable that returns the hex string representation of a UUID.new object., (*6)
<?php
$factory = $dic['UUID.HexFactory'];
$uuid4_hex = $factory();
Development
$ git clone https://github.com/GermaniaKG/UuidServiceProvider.git
$ cd UuidServiceProvider
$ composer install
Unit tests
Either copy phpunit.xml.dist to phpunit.xml and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:, (*7)
$ composer test
# or
$ vendor/bin/phpunit