public function resolveWriter(ResourceUri $resource)
    {
        if (! array_key_exists($resource->getProtocol(), $this->protocolWriterIndexes)) {
            throw new \RuntimeException('Unsupported protocol: ' . $resource->getProtocol() . '( ' . $resource  . ')');
        }

        /** @var int $index */
        $index = $this->protocolWriterIndexes[$resource->getProtocol()];

        return $this->writers[$index];
    }