AcmePhp\Cli\Action\AbstractFlysystemAction::mirrorFile PHP Method

mirrorFile() private method

private mirrorFile ( string $path, League\Flysystem\FilesystemInterface $remote, League\Flysystem\AdapterInterface $remoteAdapter )
$path string
$remote League\Flysystem\FilesystemInterface
$remoteAdapter League\Flysystem\AdapterInterface
    private function mirrorFile($path, FilesystemInterface $remote, AdapterInterface $remoteAdapter)
    {
        $masterContent = $this->master->read($path);
        if (!is_string($masterContent)) {
            throw new \RuntimeException(sprintf('File %s could not be read on master storage', $path));
        }
        $isOnRemote = $remote->has($path);
        if ($isOnRemote && !$remote->update($path, $masterContent)) {
            throw $this->createRuntimeException('File', $path, 'updated', $remoteAdapter);
        } elseif (!$isOnRemote && !$remote->write($path, $masterContent)) {
            throw $this->createRuntimeException('File', $path, 'created', $remoteAdapter);
        }
    }