PHP code example of crudle / entity
1. Go to this page and download the library: Download crudle/entity 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/ */
crudle / entity example snippets
use Crudle\Entity\Identity\IdentifiedByUuid;
use Crudle\Entity\Property\PrivateImmutableAttributes;
class MyEntity
{
use IdentifiedByUuid, PrivateImmutableAttributes;
/**
* @param string $description
* @return MyEntity
*/
public function setDescription(string $description): MyEntity
{
return $this->set('description', $description);
}
/**
* @return string
* @throws \Crudle\Entity\Exception\UndefinedException
* When a description has not yet been set
*/
public function getDescription(): string
{
return $this->getOrFail('description');
}
}
$myEntity = new MyEntity;
$myEntity->getId(); // Crudle\Entity\Identity\Uuid
$myOtherEntity = new MyEntity('fa8588c6-166d-400d-9b13-561704027e94');