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 86ecbe2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 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
1 change: 0 additions & 1 deletion src/Resources/config/app/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ sylius_resource:
sylius_refund.customer_billing_data:
classes:
model: Sylius\RefundPlugin\Entity\CustomerBillingData
factory: Sylius\RefundPlugin\Factory\CustomerBillingDataFactory

sylius_mailer:
emails:
Expand Down

0 comments on commit 86ecbe2

Please sign in to comment.