wip: finalize implementation
This commit is contained in:
1 parent
dc7ed0728a
commit
434c4d0a11
20 files changed
+112
-224
No files matched your search
@@ -17,7 +17,7 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
||||
class Insurance
|
||||
{
|
||||
#[Groups(['api:single', 'api:list'])]
|
||||
public string|int|null $id = null;
|
||||
public string|null $id = null;
|
||||
|
||||
#[Groups(['api:single', 'api:list'])]
|
||||
public ?string $code = null;
|
||||
@@ -105,11 +105,6 @@ class Insurance
|
||||
*/
|
||||
public array $individualPrice = [];
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string) $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subType, with virtual 'PKG' subType for insurance packages.
|
||||
*
|
||||
|
||||
@@ -34,7 +34,7 @@ trait SortByPriceTrait
|
||||
*/
|
||||
protected function sortByPrice(array $items): array
|
||||
{
|
||||
usort($items, function (object $a, object $b) {
|
||||
uasort($items, function (object $a, object $b) {
|
||||
$priceA = $a->price ?? 0;
|
||||
$priceB = $b->price ?? 0;
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ class InsuranceParser extends AbstractParser
|
||||
$individualInsurances = [];
|
||||
$xmlContent->filterXPath('//versicherungen/versicherung')
|
||||
->each(function (Crawler $node) use (&$individualInsurances, &$insurances) {
|
||||
$id = (int) $node->attr('idbuspro'); // Individual insurances have int IDs
|
||||
$isComplementary = $this->getBoolAttributeValue($node->attr('zusatzversicherung'));
|
||||
|
||||
// Parse all individual insurances for reference lookup
|
||||
@@ -110,7 +109,7 @@ class InsuranceParser extends AbstractParser
|
||||
|
||||
// Basic identifiers - packages have string IDs with 'P' prefix, individual insurances have int IDs
|
||||
$idValue = $node->attr('idbuspro');
|
||||
$insurance->id = $isPackage ? $idValue : (int) $idValue;
|
||||
$insurance->id = $idValue;
|
||||
$insurance->code = $node->attr('code');
|
||||
$insurance->label = $this->normalizeInsuranceLabel($node->attr('bezeichnung'));
|
||||
$insurance->subType = $node->attr('unterart');
|
||||
@@ -169,7 +168,7 @@ class InsuranceParser extends AbstractParser
|
||||
->each(function (Crawler $packageNode) use (&$referencedIds) {
|
||||
$packageNode->filterXPath('.//enthalteneversicherung')
|
||||
->each(function (Crawler $refNode) use (&$referencedIds) {
|
||||
$referencedIds[] = (int) $refNode->attr('idbuspro'); // Referenced insurances are always int IDs
|
||||
$referencedIds[] = $refNode->attr('idbuspro');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -188,7 +187,7 @@ class InsuranceParser extends AbstractParser
|
||||
$ids = [];
|
||||
$node->filterXPath('.//enthalteneversicherungen/enthalteneversicherung')
|
||||
->each(function (Crawler $insuranceNode) use (&$ids) {
|
||||
$ids[] = (int) $insuranceNode->attr('idbuspro'); // Individual insurance IDs are always int
|
||||
$ids[] = $insuranceNode->attr('idbuspro'); // Individual insurance IDs are always int
|
||||
});
|
||||
|
||||
return $ids;
|
||||
|
||||
Reference in new issue
Block a user