protected function resolveConflicts($conflictResolution, $fileID)
    {
        // If overwrite is requested, simply put
        if ($conflictResolution === AssetStore::CONFLICT_OVERWRITE) {
            return $fileID;
        }

        // Otherwise, check if this exists
        $exists = $this->applyToFileIDOnFilesystem(function () {
            return true;
        }, $fileID);
        if (!$exists) {
            return $fileID;
        }

        // Flysystem defaults to use_existing
        switch ($conflictResolution) {
            // Throw tantrum
            case static::CONFLICT_EXCEPTION: {
                throw new InvalidArgumentException("File already exists at path {$fileID}");
            }

            // Rename
            case static::CONFLICT_RENAME: {
                foreach ($this->fileGeneratorFor($fileID) as $candidate) {
                    $exists = $this->applyToFileIDOnFilesystem(function () {
                        return true;
                    }, $candidate);
                    if (!$exists) {
                        return $candidate;
                    }
                }

                throw new InvalidArgumentException("File could not be renamed with path {$fileID}");
            }

            // Use existing file
            case static::CONFLICT_USE_EXISTING:
            default: {
                return false;
            }
        }
    }
protected function resolveConflicts($conflictResolution, $fileID)
    {
        // If overwrite is requested, simply put
        if ($conflictResolution === AssetStore::CONFLICT_OVERWRITE) {
            return $fileID;
        }

        // Otherwise, check if this exists
        $exists = $this->applyToFileIDOnFilesystem(function () {
            return true;
        }, $fileID);
        if (!$exists) {
            return $fileID;
        }

        // Flysystem defaults to use_existing
        switch ($conflictResolution) {
            // Throw tantrum
            case static::CONFLICT_EXCEPTION: {
                throw new InvalidArgumentException("File already exists at path {$fileID}");
            }

            // Rename
            case static::CONFLICT_RENAME: {
                foreach ($this->fileGeneratorFor($fileID) as $candidate) {
                    $exists = $this->applyToFileIDOnFilesystem(function () {
                        return true;
                    }, $candidate);
                    if (!$exists) {
                        return $candidate;
                    }
                }

                throw new InvalidArgumentException("File could not be renamed with path {$fileID}");
            }

            // Use existing file
            case static::CONFLICT_USE_EXISTING:
            default: {
                return false;
            }
        }
    }
protected function resolveConflicts ( $ conflictResolution , $ fileID ) { // If overwrite is requested, simply put if ( $ conflictResolution === AssetStore :: CONFLICT_OVERWRITE ) { return $ fileID ; } // Otherwise, check if this exists $ exists = $ this -> applyToFileIDOnFilesystem ( function ( ) { return true ; } , $ fileID ) ; if ( ! $ exists ) { return $ fileID ; } // Flysystem defaults to use_existing switch ( $ conflictResolution ) { // Throw tantrum case static :: CONFLICT_EXCEPTION : { throw new InvalidArgumentException ( "File already exists at path {$fileID}" ) ; } // Rename case static :: CONFLICT_RENAME : { foreach ( $ this -> fileGeneratorFor ( $ fileID ) as $ candidate ) { $ exists = $ this -> applyToFileIDOnFilesystem ( function ( ) { return true ; } , $ candidate ) ; if ( ! $ exists ) { return $ candidate ; } } throw new InvalidArgumentException ( "File could not be renamed with path {$fileID}" ) ; } // Use existing file case static :: CONFLICT_USE_EXISTING : default : { return false ; } } }
Determine the path that should be written to, given the conflict resolution scheme

@param string $conflictResolution
@param string $fileID
@return string|false Safe filename to write to. If false, then don't write, and use existing file.
@throws InvalidArgumentException
Determine the path that should be written to given the conflict resolution scheme