Browse Source

Fast mode

pull/3/head
Richard Dern 3 months ago
parent
commit
32e0607c2b
  1. 3
      config/analyzer.php
  2. 24
      package/Analyzer.php
  3. 3
      package/Contracts/Analyzer.php

3
config/analyzer.php

@ -34,7 +34,8 @@ return [
'html' => [
'groups' => [],
'analyzers' => [
\Cyca\Analyzer\Html\HtmlAnalyzer::class
\Cyca\Analyzer\Html\HtmlAnalyzer::class,
\Cyca\Analyzer\FeedDiscoverer\FeedDiscoverer::class
]
]

24
package/Analyzer.php

@ -83,6 +83,13 @@ class Analyzer extends GenericObject
*/
protected ?Filesystem $fileSystem = null;
/**
* Should we enable the fast mode ?
*
* @var boolean
*/
protected $fastMode = false;
# ----| Accessors |---------------------------------------------------------
/**
@ -128,6 +135,19 @@ class Analyzer extends GenericObject
# ----| Methods |-----------------------------------------------------------
# --------------------------------------------------------------------------
/**
* Indicates we should use the fast mode. Only of subset of data is
* returned. This subset is determined by each analyzer.
*
* @return self
*/
public function fast(): self
{
$this->fastMode = true;
return $this;
}
/**
* Analyze a URL. Uses Cyca's Fetcher to fetch file at target URL first.
*
@ -237,12 +257,12 @@ class Analyzer extends GenericObject
$attributes = $this->toArray();
foreach ($analyzers as $className) {
$instance = new $className;
$instance = new $className;
$instance
->setFilesystem($this->fileSystem)
->setDiscoveredAttributes($attributes)
->analyze();
->analyze($this->fastMode);
$attributes['analyzers'][$className] = $instance->toArray();
}

3
package/Contracts/Analyzer.php

@ -23,7 +23,8 @@ interface Analyzer
/**
* Launch document's analyzis.
*
* @param bool $fastMode
* @return void
*/
public function analyze(): void;
public function analyze(bool $fastMode = false): void;
}

Loading…
Cancel
Save