public function createDocumentFromSource(
        ObjectIdInterface $source,
        array $properties = [],
        ObjectIdInterface $folderId = null,
        VersioningState $versioningState = null,
        array $policies = [],
        array $addAces = [],
        array $removeAces = []
    ) {
        if (!$source instanceof CmisObjectInterface) {
            $sourceObject = $this->getObject($source);
        } else {
            $sourceObject = $source;
        }

        $type = $sourceObject->getType();
        $secondaryTypes = $sourceObject->getSecondaryTypes();

        if ($secondaryTypes === null) {
            $secondaryTypes = [];
        }

        if (!BaseTypeId::cast($type->getBaseTypeId())->equals(BaseTypeId::CMIS_DOCUMENT)) {
            throw new CmisInvalidArgumentException('Source object must be a document!');
        }

        $objectId = $this->getBinding()->getObjectService()->createDocumentFromSource(
            $this->getRepositoryId(),
            $source->getId(),
            $this->getObjectFactory()->convertProperties(
                $properties,
                $type,
                $secondaryTypes,
                self::$createAndCheckoutUpdatability
            ),
            $folderId === null ? null : $folderId->getId(),
            $versioningState,
            $this->getObjectFactory()->convertPolicies($policies),
            $this->getObjectFactory()->convertAces($addAces),
            $this->getObjectFactory()->convertAces($removeAces),
            null
        );

        if ($objectId === null) {
            return null;
        }

        return $this->createObjectId($objectId);
    }