Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Magento\InventoryInStorePickupApi\Model\SearchRequest\Area\Pipeline;
use Magento\InventorySourceSelectionApi\Api\Data\AddressInterface;
use Magento\InventorySourceSelectionApi\Api\Data\AddressInterfaceFactory;
use Psr\Log\LoggerInterface;

/**
* Provide associated list of Source codes and distance to them in KM.
Expand Down Expand Up @@ -47,22 +48,30 @@ class GetDistanceToSources
*/
private $searchTermPipeline;

/**
* @var LoggerInterface
*/
private $logger;

/**
* @param GetLatsLngsFromAddressInterface $getLatsLngsFromAddress
* @param GetOrderedDistanceToSources $getOrderedDistanceToSources
* @param AddressInterfaceFactory $addressInterfaceFactory
* @param Pipeline $searchTermPipeline
* @param Logger $logger
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @param documentation shows 'Logger' but the actual parameter type is 'LoggerInterface'. This should be '@param LoggerInterface $logger' to match the type hint.

Suggested change
* @param Logger $logger
* @param LoggerInterface $logger

Copilot uses AI. Check for mistakes.

*/
public function __construct(
GetLatsLngsFromAddressInterface $getLatsLngsFromAddress,
GetOrderedDistanceToSources $getOrderedDistanceToSources,
AddressInterfaceFactory $addressInterfaceFactory,
Pipeline $searchTermPipeline
Pipeline $searchTermPipeline,
LoggerInterface $logger
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$logger should be null by default

Suggested change
LoggerInterface $logger
LoggerInterface $logger=null

) {
$this->getLatsLngsFromAddress = $getLatsLngsFromAddress;
$this->getOrderedDistanceToSources = $getOrderedDistanceToSources;
$this->addressInterfaceFactory = $addressInterfaceFactory;
$this->searchTermPipeline = $searchTermPipeline;
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
}

/**
Expand Down Expand Up @@ -108,6 +117,7 @@ private function getDistanceToSources(AreaInterface $area): array
try {
$latsLngs = $this->getLatsLngsFromAddress->execute($sourceSelectionAddress);
} catch (LocalizedException $exception) {
$this->logger->error($exception->getMessage());
return [];
}

Expand Down