1. Go to this page and download the library: Download elielfc/to-class 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/ */
elielfc / to-class example snippets
/*...*/
use ElielFC\ToClass\{
Contract\ToClass,
BaseToClass
};
class EntityToClass extends BaseToClass implements ToClass
{
public int $id;
public bool $active;
}
$entity = new EntityToClass();
$entity->make(["id" => 10, "active" => true, "name" => "Eliel F Canivarolli", /*...*/]);
$entity->make('{"id":"10", "active":"true", "name":"Eliel F Canivarolli"}');
/*...*/
public bool $active;
public function setActiveAttribute(mixed $value): void
{
$this->active = $value === "VERDADEIRO";
}
/* Ex: Atribuição em um array */
public array $phone:
public function setPhoneAttribute(mixed $value): void
{
$this->phone[] = $value;
}
/*...*/