Files
oficial/app/common/Ideal/Model.php

33 lines
668 B
PHP
Raw Normal View History

<?php
namespace Incoviba\Common\Ideal;
use Incoviba\Common\Define;
abstract class Model implements Define\Model
{
public int $id;
protected array $factories;
public function addFactory(string $property, Define\Repository\Factory $factory): Model
{
$this->factories[$property] = $factory;
return $this;
}
protected function runFactory(string $property): mixed
{
2023-09-13 18:51:46 -03:00
if (isset($this->factories[$property])) {
return $this->factories[$property]->run();
}
return null;
}
public function jsonSerialize(): mixed
{
return [
'id' => $this->id
];
}
}