PHP code example of jeckel-lab / identity-contract

1. Go to this page and download the library: Download jeckel-lab/identity-contract library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jeckel-lab / identity-contract example snippets


final readonly class CarId extends AbstractIntIdentity {}

$id = CarId::from(25);

use JeckelLab\IdentityContract\AbstractUuidIdentity;

final readonly class UserId extends AbstractUuidIdentity {}

$id = UserId::from("d2fbc6c0-0497-42f1-8ece-8840641b67f0");

// or

$id = UserId::new();

// Generating twice same identity return same object

$id1 = UserId::from("d2fbc6c0-0497-42f1-8ece-8840641b67f0");
$id2 = UserId::from("d2fbc6c0-0497-42f1-8ece-8840641b67f0");

var_dump($id1 === $id2); // true