commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
ItemStateBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
23 final class ItemStateBuilder implements Builder
24 {
29  private $quantity;
30 
35  private $state;
36 
41  public function getQuantity()
42  {
43  return $this->quantity;
44  }
45 
52  public function getState()
53  {
54  return $this->state instanceof StateKeyReferenceBuilder ? $this->state->build() : $this->state;
55  }
56 
61  public function withQuantity(?int $quantity)
62  {
63  $this->quantity = $quantity;
64 
65  return $this;
66  }
67 
72  public function withState(?StateKeyReference $state)
73  {
74  $this->state = $state;
75 
76  return $this;
77  }
78 
83  public function withStateBuilder(?StateKeyReferenceBuilder $state)
84  {
85  $this->state = $state;
86 
87  return $this;
88  }
89 
90  public function build(): ItemState
91  {
92  return new ItemStateModel(
93  $this->quantity,
94  $this->state instanceof StateKeyReferenceBuilder ? $this->state->build() : $this->state
95  );
96  }
97 
98  public static function of(): ItemStateBuilder
99  {
100  return new self();
101  }
102 }
withStateBuilder(?StateKeyReferenceBuilder $state)