Skip to content

Commit

Permalink
Assert creation of billing
Browse files Browse the repository at this point in the history
  • Loading branch information
arti0090 committed Jun 15, 2021
1 parent 1576c43 commit 49c7162
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/Factory/CustomerBillingDataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\RefundPlugin\Entity\CustomerBillingDataInterface;
use Webmozart\Assert\Assert;

class CustomerBillingDataFactory implements CustomerBillingDataFactoryInterface
{
Expand Down Expand Up @@ -63,6 +64,13 @@ public function createWithData(

public function createWithAddress(AddressInterface $address): CustomerBillingDataInterface
{
Assert::notNull($address->getFirstName());
Assert::notNull($address->getLastName());
Assert::notNull($address->getStreet());
Assert::notNull($address->getPostcode());
Assert::notNull($address->getCountryCode());
Assert::notNull($address->getCity());

return $this->createWithData(
$address->getFirstName(),
$address->getLastName(),
Expand Down
6 changes: 0 additions & 6 deletions src/Generator/CreditMemoGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ public function generate(

private function getFromAddress(AddressInterface $address): CustomerBillingDataInterface
{
Assert::notNull($address->getFirstName());
Assert::notNull($address->getLastName());
Assert::notNull($address->getStreet());
Assert::notNull($address->getPostcode());
Assert::notNull($address->getCountryCode());

return $this->customerBillingDataFactory->createWithAddress($address);
}

Expand Down

0 comments on commit 49c7162

Please sign in to comment.