/** * Returns entity object * * @return Base */ public static function getEntity() { $class = get_called_class(); if (!isset(static::$entity[$class])) { static::$entity[$class] = Base::getInstance($class); } return static::$entity[$class]; }
/** * @param Base|Query|string $source * @throws Main\ArgumentException */ public function __construct($source) { if ($source instanceof $this) { $this->init_entity = Base::getInstanceByQuery($source); } elseif ($source instanceof Base) { $this->init_entity = $source; } elseif (is_string($source)) { $this->init_entity = Base::getInstance($source); } else { throw new Main\ArgumentException(sprintf('Unknown source type "%s" for new %s', gettype($source), __CLASS__)); } }