public static function factory($prefix, $name = null)
    {
        $calledClass = get_called_class();

        /** @var \PhalconRest\Api\ApiResource $resource */
        $resource = new $calledClass($prefix);

        if (!$resource->getItemKey()) {
            $resource->itemKey('items');
        }

        if (!$resource->getCollectionKey()) {
            $resource->collectionKey('items');
        }

        if (!$resource->getTransformer()) {
            $resource->transformer(ModelTransformer::class);
        }

        if (!$resource->getHandler()) {
            $resource->setHandler(CrudResourceController::class);
        }

        if (!$resource->getName() && $name) {
            $resource->name($name);
        }

        if ($name) {
            $resource->name($name);
        }

        return $resource;
    }