refactor: inject AgeConstraintParserRegistry into TravelParser
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\Traits;
|
||||
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
trait XmlParserTrait
|
||||
{
|
||||
protected function getStringOrNullValue(Crawler $node): ?string
|
||||
{
|
||||
return 0 < $node->count() ? $node->text() : null;
|
||||
}
|
||||
|
||||
protected function getIntOrNullValue(Crawler $node): ?int
|
||||
{
|
||||
return 0 < $node->count() ? (int) $node->text() : null;
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,27 @@
|
||||
namespace App\BusProNet\XmlLoader;
|
||||
|
||||
use App\BusProNet\Traits\TypeConversionTrait;
|
||||
use App\BusProNet\Traits\XmlParserTrait;
|
||||
use League\Flysystem\FilesystemOperator;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
|
||||
abstract class AbstractLoader
|
||||
{
|
||||
use TypeConversionTrait;
|
||||
use XmlParserTrait;
|
||||
|
||||
public function __construct(
|
||||
protected readonly CacheInterface $cache,
|
||||
protected readonly FilesystemOperator $xmlExport,
|
||||
) {
|
||||
}
|
||||
|
||||
protected function getStringOrNullValue(Crawler $node): ?string
|
||||
{
|
||||
return 0 < $node->count() ? $node->text() : null;
|
||||
}
|
||||
|
||||
protected function getIntOrNullValue(Crawler $node): ?int
|
||||
{
|
||||
return 0 < $node->count() ? (int) $node->text() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ use Symfony\Component\DomCrawler\Crawler;
|
||||
*/
|
||||
class TravelParser extends AbstractParser
|
||||
{
|
||||
private AgeConstraintParserRegistry $ageConstraintRegistry;
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
@@ -31,9 +29,9 @@ class TravelParser extends AbstractParser
|
||||
Constants::PSEUDO_PRICE_ROOM_CODE,
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ageConstraintRegistry = new AgeConstraintParserRegistry();
|
||||
public function __construct(
|
||||
private readonly AgeConstraintParserRegistry $ageConstraintRegistry = new AgeConstraintParserRegistry(),
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user