germania-kg / uuidserviceprovider
1.2.2
2022-05-30 13:38 UTC
Requires
- pimple/pimple: ^3.0
- ramsey/uuid: ^3.7|^4.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-11-16 17:58:17 UTC
README
Pimple Service Provider for working with Ben Ramsey's ramsey/uuid package
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.
<?php $uuid4 = $dic['UUID.new'];
UUID.new.hex
Returns the hex string representation of a UUID.new object.
<?php $uuid4_hex = $dic['UUID.new.hex'];
UUID.Factory
Returns a callable that returns UUID object as Ramsey\Uuid\Uuid instance.
<?php $factory = $dic['UUID.Factory']; $uuid4 = $factory();
UUID.HexFactory
Returns a callable that returns the hex string representation of a UUID.new object.
<?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:
$ composer test # or $ vendor/bin/phpunit