Browse Source

Replaced / with _ in mime types for configuration checkings

pull/3/head
Richard Dern 3 months ago
parent
commit
e4da70348d
  1. 2
      config/analyzer.php
  2. 21
      package/Analyzer.php

2
config/analyzer.php

@ -17,7 +17,7 @@ return [
*/
'analyzers' => [
'text/html' => [
'text_html' => [
'groups' => [
'html'
],

21
package/Analyzer.php

@ -8,6 +8,7 @@ use Cyca\Fetcher\Facades\Fetcher;
use Cyca\Helpers\Helpers\GenericObject;
use Exception;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Support\Str;
use League\Flysystem\FileNotFoundException;
/**
@ -133,7 +134,7 @@ class Analyzer extends GenericObject
*/
public function analyzeUrl(string $url): self
{
$this->source = self::SOURCE_URL;
$this->source = self::SOURCE_URL;
$this->sourceUrl = $url;
$client = Fetcher::fetch($url);
@ -229,7 +230,6 @@ class Analyzer extends GenericObject
$analyzers = $this->getAnalyzers();
foreach ($analyzers as $className) {
//TODO
}
}
@ -242,14 +242,15 @@ class Analyzer extends GenericObject
protected function getAnalyzers(): array
{
$classes = [];
$groups = config(sprintf('analyzer.analyzers.%s.groups', $this->mimeType), []);
$analyzers = config(sprintf('analyzer.analyzers.%s.analyzers', $this->mimeType), []);
$mimeType = Str::replace('/', '_', $this->mimeType);
$groups = config(sprintf('analyzer.analyzers.%s.groups', $mimeType), []);
$analyzers = config(sprintf('analyzer.analyzers.%s.analyzers', $mimeType), []);
foreach ($groups as $subGroup) {
$classes += $this->getAnalyzersPerGroup($subGroup);
$classes = array_merge($classes, $this->getAnalyzersPerGroup($subGroup));
}
$classes += $analyzers;
$classes = array_merge($classes, $analyzers);
return $classes;
}
@ -264,14 +265,14 @@ class Analyzer extends GenericObject
protected function getAnalyzersPerGroup(string $groupName): array
{
$classes = [];
$groups = config(sprintf('analyzer.group.%s.groups', $groupName), []);
$analyzers = config(sprintf('analyzer.group.%s.analyzers', $groupName), []);
$groups = config(sprintf('analyzer.groups.%s.groups', $groupName), []);
$analyzers = config(sprintf('analyzer.groups.%s.analyzers', $groupName), []);
foreach ($groups as $subGroup) {
$classes += $this->getAnalyzersPerGroup($subGroup);
$classes = array_merge($classes, $this->getAnalyzersPerGroup($subGroup));
}
$classes += $analyzers;
$classes = array_merge($classes, $analyzers);
return $classes;
}

Loading…
Cancel
Save