feat: match pickups by name
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Teamer;
|
||||
|
||||
use App\BusProNet\DataProvider\PickupDataProvider;
|
||||
use App\Entity\Teamer;
|
||||
|
||||
class PickupResolver
|
||||
{
|
||||
public function __construct(private readonly PickupDataProvider $pickupDataProvider)
|
||||
{
|
||||
}
|
||||
|
||||
public function hasPickup(?int $pickupId, Teamer $teamer): bool
|
||||
{
|
||||
if (null === $pickupId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pickup = $this->pickupDataProvider->get($pickupId);
|
||||
|
||||
if (null === $pickup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$teamerPickups = array_map(function (int $id) {
|
||||
return $this->pickupDataProvider->get($id);
|
||||
}, $teamer->getPickups());
|
||||
|
||||
foreach ($teamerPickups as $teamerPickup) {
|
||||
$teamerPickupCity = trim($teamerPickup->getCity());
|
||||
$pickupCity = trim($pickup->getCity());
|
||||
if ($teamerPickupCity === $pickupCity) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user