Skip to content

Commit

Permalink
Fix basic PhpStan errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek committed Sep 12, 2022
1 parent 66c3945 commit 16f0ca6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
29 changes: 14 additions & 15 deletions src/Api/CmsOrderEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,9 @@ public function actionDefault(
$sum = [];
$return = [];
foreach ($feed['orders'] as $order) {
assert($order instanceof Order);
$documents = [];
if (isset($feed['invoices'][$order->getId()])) {
$invoice = $feed['invoices'][$order->getId()];
assert($invoice instanceof InvoiceInterface);
$documents[] = new CmsOrderFeedDocument(
url: $invoice->getDownloadLink(),
label: '🧾',
Expand Down Expand Up @@ -160,18 +158,20 @@ public function actionDefault(
premium: $order->getCustomer()->isPremium(),
ban: $order->getCustomer()->isBan(),
),
delivery: new CmsOrderFeedDelivery(
id: $deliveryItem?->getId(),
name: $deliveryItem?->getLabel(),
price: $order->getDeliveryPrice()->render(true),
color: $deliveryItem?->getColor(),
),
payment: new CmsOrderFeedPayment(
id: $paymentItem?->getId(),
name: $paymentItem?->getName(),
price: $order->getPaymentPrice()->render(true),
color: $paymentItem?->getColor(),
),
delivery: $deliveryItem !== null
? new CmsOrderFeedDelivery(
id: $deliveryItem->getId(),
name: $deliveryItem->getLabel(),
price: $order->getDeliveryPrice()->render(true),
color: $deliveryItem->getColor(),
) : null,
payment: $paymentItem !== null
? new CmsOrderFeedPayment(
id: $paymentItem->getId(),
name: $paymentItem->getName(),
price: $order->getPaymentPrice()->render(true),
color: $paymentItem->getColor(),
) : null,
items: (static function ($items): array {
$return = [];
foreach ($items as $item) {
Expand All @@ -194,7 +194,6 @@ public function actionDefault(
payments: (static function ($items): array {
$return = [];
foreach ($items as $item) {
assert($item instanceof OrderOnlinePayment);
$return[] = [
'id' => $item->getId(),
];
Expand Down
4 changes: 2 additions & 2 deletions src/Api/DTO/CmsOrderFeedList.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(
public string $updatedDate,
public int $package,
public CmsOrderFeedCustomer $customer,
public CmsOrderFeedDelivery $delivery,
public CmsOrderFeedPayment $payment,
public ?CmsOrderFeedDelivery $delivery,
public ?CmsOrderFeedPayment $payment,
public array $items,
public array $documents,
public array $payments,
Expand Down
2 changes: 1 addition & 1 deletion src/Notification/OrderNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function sendNotification(
}
if ($notification->getType()->value === OrderNotificationType::Email->value) {
$this->sendEmail($order, $notification->getStatus(), $attachments);
} elseif ($notification->getType()->value === OrderNotificationType::Sms->value) {
} else {
$this->sendSms($order, $notification->getStatus());
}
}
Expand Down

0 comments on commit 16f0ca6

Please # to comment.