replaced unnecessary double quotes

This commit is contained in:
jona 2024-12-21 12:23:51 +01:00 committed by Jan Böhmer
parent 358b66e62d
commit ed1076fa5a

View file

@ -75,31 +75,31 @@ class InfoProviderController extends AbstractController
private function matchResultsToKnownParts(array $partsList): array private function matchResultsToKnownParts(array $partsList): array
{ {
//we need a manufacturer object to look for a manufacturer //we need a manufacturer object to look for a manufacturer
$manufacturerQb = $this->em->getRepository(Manufacturer::class)->createQueryBuilder("manufacturer"); $manufacturerQb = $this->em->getRepository(Manufacturer::class)->createQueryBuilder('manufacturer');
$manufacturerQb->where($manufacturerQb->expr()->like("LOWER(manufacturer.name)", "LOWER(:manufacturer_name)")); $manufacturerQb->where($manufacturerQb->expr()->like('LOWER(manufacturer.name)', 'LOWER(:manufacturer_name)'));
//check if both manufacturer and Manufacturer part namber matches. If so, it must be the same part //check if both manufacturer and Manufacturer part namber matches. If so, it must be the same part
//use LOWER to make the search independent of case //use LOWER to make the search independent of case
$mpnQb = $this->em->getRepository(Part::class)->createQueryBuilder("part"); $mpnQb = $this->em->getRepository(Part::class)->createQueryBuilder('part');
$mpnQb->where($mpnQb->expr()->like("LOWER(part.manufacturer_product_number)", "LOWER(:mpn)")); $mpnQb->where($mpnQb->expr()->like('LOWER(part.manufacturer_product_number)', 'LOWER(:mpn)'));
$mpnQb->andWhere($mpnQb->expr()->eq("part.manufacturer", ":manufacturer")); $mpnQb->andWhere($mpnQb->expr()->eq('part.manufacturer', ':manufacturer'));
foreach ($partsList as $index => $part) { foreach ($partsList as $index => $part) {
$manufacturerQb->setParameter("manufacturer_name", $part["dto"]->manufacturer); $manufacturerQb->setParameter('manufacturer_name', $part['dto']->manufacturer);
$manufacturers = $manufacturerQb->getQuery()->getResult(); $manufacturers = $manufacturerQb->getQuery()->getResult();
if(!$manufacturers) { if(!$manufacturers) {
continue; continue;
} }
$mpnQb->setParameter("manufacturer", $manufacturers); $mpnQb->setParameter('manufacturer', $manufacturers);
$mpnQb->setParameter("mpn", $part["dto"]->mpn); $mpnQb->setParameter('mpn', $part['dto']->mpn);
$localParts = $mpnQb->getQuery()->getResult(); $localParts = $mpnQb->getQuery()->getResult();
if(!$localParts) { if(!$localParts) {
continue; continue;
} }
//We only use the first matching part. If a user already has duplicate parts they will get a random one //We only use the first matching part. If a user already has duplicate parts they will get a random one
$partsList[$index]["localPart"] = $localParts[0]; $partsList[$index]['localPart'] = $localParts[0];
} }
return $partsList; return $partsList;
} }
@ -136,7 +136,7 @@ class InfoProviderController extends AbstractController
// modify the array to an array of arrays that has a field for a matching local Part // modify the array to an array of arrays that has a field for a matching local Part
// the advantage to use that format even when we don't look for local parts is that we // the advantage to use that format even when we don't look for local parts is that we
// always work with the same interface // always work with the same interface
$results = array_map(function ($result) {return ["dto" => $result,"localPart" => null];}, $results); $results = array_map(function ($result) {return ['dto' => $result, 'localPart' => null];}, $results);
if(!$update_target) { if(!$update_target) {
$results = $this->matchResultsToKnownParts($results); $results = $this->matchResultsToKnownParts($results);
} }