public function scan()
    {
        //Sets the full base url
        $fullBaseUrl = $this->getConfig('fullBaseUrl', Configure::read('App.fullBaseUrl') ?: 'http://localhost');
        is_true_or_fail(is_url($fullBaseUrl), __d('link-scanner', 'Invalid full base url `{0}`', $fullBaseUrl), InvalidArgumentException::class);
        $this->hostname = get_hostname_from_url($fullBaseUrl);

        $this->_createLockFile();
        $this->startTime = time();

        $maxNestingLevel = ini_set('xdebug.max_nesting_level', -1);

        try {
            $this->dispatchEvent('LinkScanner.scanStarted', [$this->startTime, $fullBaseUrl]);
            $this->_recursiveScan($fullBaseUrl);
            $this->endTime = time();
            $this->dispatchEvent('LinkScanner.scanCompleted', [$this->startTime, $this->endTime, $this->ResultScan]);
        } finally {
            ini_set('xdebug.max_nesting_level', $maxNestingLevel);
            @unlink($this->lockFile);
        }

        return $this;
    }