1: <?php
2: /*
3: * This file was automatically generated.
4: */
5: namespace Worldline\Acquiring\Sdk\V1\Domain;
6:
7: use UnexpectedValueException;
8:
9: /**
10: * @package Worldline\Acquiring\Sdk\V1\Domain
11: */
12: class ByMerchantIds extends MerchantScope
13: {
14: const MERCHANT_SCOPE_TYPE = 'BY_MERCHANT_IDS';
15:
16: /**
17: * @var MerchantIdItem[]|null
18: */
19: public ?array $merchantIds = null;
20:
21: public function __construct()
22: {
23: $this->merchantScopeType = self::MERCHANT_SCOPE_TYPE;
24: }
25:
26: /**
27: * @return object
28: */
29: public function toObject(): object
30: {
31: $object = parent::toObject();
32: if (!is_null($this->merchantIds)) {
33: $object->merchantIds = [];
34: foreach ($this->merchantIds as $element) {
35: if (!is_null($element)) {
36: $object->merchantIds[] = $element->toObject();
37: }
38: }
39: }
40: $object->merchantScopeType = self::MERCHANT_SCOPE_TYPE;
41: return $object;
42: }
43:
44: /**
45: * @param object $object
46: *
47: * @return $this
48: * @throws UnexpectedValueException
49: */
50: public function fromObject(object $object): ByMerchantIds
51: {
52: parent::fromObject($object);
53: $this->merchantScopeType = self::MERCHANT_SCOPE_TYPE;
54: if (property_exists($object, 'merchantIds')) {
55: if (!is_array($object->merchantIds) && !is_object($object->merchantIds)) {
56: throw new UnexpectedValueException('value \'' . print_r($object->merchantIds, true) . '\' is not an array or object');
57: }
58: $this->merchantIds = [];
59: foreach ($object->merchantIds as $element) {
60: $value = new MerchantIdItem();
61: $this->merchantIds[] = $value->fromObject($element);
62: }
63: }
64: return $this;
65: }
66: }
67: