refactor search functionality; remove deprecated services and implement new action and task classes for improved structure and maintainability
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Search\Tasks;
|
||||
|
||||
use DiDom\Document;
|
||||
|
||||
class GetBreadcrumbFromHtmlTask
|
||||
{
|
||||
public function run(string $html): ?string
|
||||
{
|
||||
$document = new Document($html);
|
||||
$breadcrumbs = $document->first('ol.breadcrumb')?->find('li') ?? [];
|
||||
|
||||
foreach ($breadcrumbs as $index => $breadcrumb) {
|
||||
if ($index === 2) { // Индексация с 0 → третий элемент = 2
|
||||
return trim($breadcrumb->text());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user