PHP code example of apie / common-value-objects

1. Go to this page and download the library: Download apie/common-value-objects 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/ */

    

apie / common-value-objects example snippets



use Apie\Core\Identifiers\UuidV4;
use Apie\Core\Identifiers\IdentifierInterface;

class UserIdentifier extends UuidV4 implements IdentifierInterface
{
    public static function getReferenceFor(): ReflectionClass
    {
        return new ReflectionClass(User::class);
    }
}


use Apie\Core\Entities\EntityInterface;

class User implements EntityInterface
{
    private UserIdentifier $id;

    public function __construct()
    {
        $this->id = UserIdentifier::createRandom();
    }

    public function getIdentifier(): UserIdentifier
    {
        return $this->id;
    }
}