for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Component\Core\Customer;
use Sylius\Component\Addressing\Comparator\AddressComparatorInterface;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\CustomerInterface;
/**
* @author Jan Góralski <[email protected]>
final class CustomerUniqueAddressAdder implements CustomerAddressAdderInterface
{
* @var AddressComparatorInterface
private $addressComparator;
* @param AddressComparatorInterface $addressComparator
public function __construct(AddressComparatorInterface $addressComparator)
$this->addressComparator = $addressComparator;
}
* {@inheritdoc}
public function add(CustomerInterface $customer, AddressInterface $address)
foreach ($customer->getAddresses() as $customerAddress) {
if ($this->addressComparator->equal($customerAddress, $address)) {
return;
$customer->addAddress($address);