Skip to content

Commit ff5245c

Browse files
authored
🐛 compare by id and name (#3401)
1 parent ca8fc01 commit ff5245c

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

app/Console/Commands/RefreshOperatorMappings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
use App\Services\OperatorService;
66
use Illuminate\Console\Command;
77

8-
class RefreshOperatorMappings extends Command
9-
{
8+
class RefreshOperatorMappings extends Command {
109
protected $signature = 'app:refresh-operator-mappings';
1110

1211
public function handle(): void {
13-
OperatorService::refreshFiles();
12+
$operatorService = new OperatorService();
13+
$operatorService->refreshFiles();
1414
}
1515
}

app/Services/OperatorService.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,13 @@ private function findMapping(array $operatorMappings, string $agencyId, string $
172172
]);
173173

174174
foreach($operatorMappings as $mapping) {
175-
// Compare by motis_id.
176-
if(isset($mapping['motis_id']) && (string)$mapping['motis_id'] === $agencyId) {
177-
Log::debug('Mapping found by motis_id', ['agencyId' => $agencyId]);
178-
return $mapping;
179-
}
180-
181-
// Compare by motis_name (case-insensitive).
182-
if(isset($mapping['motis_name']) &&
183-
strtolower(trim($mapping['motis_name'])) === strtolower(trim($agencyName))) {
184-
Log::debug('Mapping found by motis_name', [
185-
'agencyName' => $agencyName,
186-
'matchedName' => $mapping['motis_name'],
187-
]);
175+
if(
176+
isset($mapping['motis_id'])
177+
&& (string)$mapping['motis_id'] === $agencyId
178+
&& isset($mapping['motis_name'])
179+
&& strtolower(trim($mapping['motis_name'])) === strtolower(trim($agencyName))
180+
) {
181+
Log::debug('Mapping found', ['agencyId' => $agencyId, 'agencyName' => $agencyName]);
188182
return $mapping;
189183
}
190184
}

0 commit comments

Comments
 (0)