<?php namespace App\Utils;


abstract class Entity {
    abstract public static function builder();
    public function toArray(bool $absolute = false): array
    {
        $array = [];
        foreach ($this as $key => $value) {
            if (!$absolute || isset($value)) {
                if (is_object($value) && strpos(get_parent_class($value), 'GeneralCollection') !== false) {
                    $array[$key] = $value->toArray();
                } else {
                    $array[$key] = $value;
                }
            }
        }
        return $array;
    }
}