public function exportCommand($filename = null, $host = null)
    {
        if (!class_exists(Writer::class)) {
            $this->outputWarningForLeagueCsvPackage();
        }
        $writer = Writer::createFromFileObject(new \SplTempFileObject());
        if ($host !== null) {
            $redirects = $this->redirectStorage->getAll($host);
        } else {
            $redirects = new \AppendIterator();
            foreach ($this->redirectStorage->getDistinctHosts() as $host) {
                $redirects->append($this->redirectStorage->getAll($host));
            }
        }
        /** @var $redirect RedirectInterface */
        foreach ($redirects as $redirect) {
            $writer->insertOne([
                $redirect->getSourceUriPath(),
                $redirect->getTargetUriPath(),
                $redirect->getStatusCode(),
                $redirect->getHost()
            ]);
        }
        if ($filename === null) {
            $writer->output();
        } else {
            file_put_contents($filename, (string)$writer);
        }
    }