1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
shippingitemcollection.php
См. документацию.
1<?php
2
3namespace Sale\Handlers\Delivery\YandexTaxi\ClaimBuilder;
4
5use Bitrix\Main\Error;
6use Bitrix\Main\Localization\Loc;
7use Sale\Handlers\Delivery\YandexTaxi\Api\RequestEntity\ShippingItem;
8use Bitrix\Main\Result;
9
15final class ShippingItemCollection implements \IteratorAggregate
16{
18 private $items = [];
19
24 public function addItem(ShippingItem $item)
25 {
26 $this->items[] = $item;
27
28 return $this;
29 }
30
34 public function isValid(): Result
35 {
36 $result = new Result();
37
38 if (!$this->items)
39 {
40 return $result->addError(new Error(Loc::getMessage('SALE_YANDEX_TAXI_EMPTY_PRODUCT_LIST')));
41 }
42
43 foreach ($this->items as $item)
44 {
45 if ($item->getQuantity() <= 0)
46 {
47 return $result->addError(new Error(Loc::getMessage('SALE_YANDEX_TAXI_PRODUCT_EMPTY_QUANTITY')));
48 }
49 }
50
51 return $result;
52 }
53
57 public function getIterator()
58 {
59 return new \ArrayIterator($this->items);
60 }
61}
$result
Определения get_property_values.php:14
trait Error
Определения error.php:11