Migrate backend to Porto architecture and fix minor bugs
- Fully transitioned the backend to the Porto architectural pattern - Improved code organization and maintainability - Fixed minor bugs and inconsistencies
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Search\Services;
|
||||
|
||||
use DiDom\Document;
|
||||
|
||||
class BreadcrumbFinderService
|
||||
{
|
||||
const FILES_DIR = 'sveden';
|
||||
|
||||
public function isSameCategory($html)
|
||||
{
|
||||
return $this->getBreadcrumb($html);
|
||||
}
|
||||
|
||||
private function getBreadcrumb(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 $breadcrumb->text();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user