puzzle / uuid
Uuid as value object
Installs: 40 576
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 3
Open Issues: 0
Requires
- php: >=7.1
- puzzle/pieces: ~2.2
- ramsey/uuid: ~3.6
- symfony/validator: ~3.2
Requires (Dev)
- phpunit/phpunit: ~6.3
This package is auto-updated.
Last update: 2024-10-29 05:05:01 UTC
README
PHP 5.6 users, please use 1.x branch.
QA
Example
Value object for Uuids
<?php // Generate a valid uuid $uuid = new Uuid(); // Force uuid value $uuid = new Uuid('b85873d1-7968-4f83-94f7-3bb6bc111828'); function foo(Uuid $uuid) { // $uuid is valid ! }
Make your own uuid classes :
<?php final class PonyId extends SelfValidatedUuid {} class Pony { private $id; public function __construct(?PonyId $id = null) { if($id === null) { $id = new PonyId(); } $this->id = $id; } //... }
Changelog
2.0.0 : Drop PHP 5.6 support