getById($id); if (is_null($data)) self::notFound(static::getResourceName() . " not found"); return $data; } /** * @param $id int * @return true */ public static function deleteById($id) { $res = static::getDataAccess()->deleteById($id); if (!$res) self::notFound(static::getResourceName() . " not found"); return true; } /** * @return LuDataAccess */ protected static function getDataAccess() { return null; } public static function getAll($page = 0, $perPage = PHP_INT_MAX) { return static::getDataAccess()->getAll($page, $perPage); } public static function getResourceName() { $match = []; preg_match('/([^\\\\]*)Business$/', get_called_class(), $match); return $match[1]; } }