public function export($filename = null)
    {
        is_true_or_fail(!$this->ResultScan->isEmpty(), __d('link-scanner', 'There is no result to export. Perhaps the scan was not performed?'), RuntimeException::class);

        $filename = $filename ?: sprintf('results_%s_%s', $this->hostname, $this->startTime);
        $filename = Folder::isAbsolute($filename) ? $filename : Folder::slashTerm($this->getConfig('target')) . $filename;
        (new File($filename, true))->write(serialize($this));
        $this->dispatchEvent('LinkScanner.resultsExported', [$filename]);

        return $filename;
    }