commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ProductSearchResultBuilder.php
1<?php
2
3declare(strict_types=1);
10
18use stdClass;
19
23final class ProductSearchResultBuilder implements Builder
24{
29 private $id;
30
35 private $matchingVariants;
36
41 private $productProjection;
42
49 public function getId()
50 {
51 return $this->id;
52 }
53
61 public function getMatchingVariants()
62 {
63 return $this->matchingVariants instanceof ProductSearchMatchingVariantsBuilder ? $this->matchingVariants->build() : $this->matchingVariants;
64 }
65
73 public function getProductProjection()
74 {
75 return $this->productProjection instanceof ProductProjectionBuilder ? $this->productProjection->build() : $this->productProjection;
76 }
77
82 public function withId(?string $id)
83 {
84 $this->id = $id;
85
86 return $this;
87 }
88
93 public function withMatchingVariants(?ProductSearchMatchingVariants $matchingVariants)
94 {
95 $this->matchingVariants = $matchingVariants;
96
97 return $this;
98 }
99
104 public function withProductProjection(?ProductProjection $productProjection)
105 {
106 $this->productProjection = $productProjection;
107
108 return $this;
109 }
110
116 {
117 $this->matchingVariants = $matchingVariants;
118
119 return $this;
120 }
121
126 public function withProductProjectionBuilder(?ProductProjectionBuilder $productProjection)
127 {
128 $this->productProjection = $productProjection;
129
130 return $this;
131 }
132
133 public function build(): ProductSearchResult
134 {
135 return new ProductSearchResultModel(
136 $this->id,
137 $this->matchingVariants instanceof ProductSearchMatchingVariantsBuilder ? $this->matchingVariants->build() : $this->matchingVariants,
138 $this->productProjection instanceof ProductProjectionBuilder ? $this->productProjection->build() : $this->productProjection
139 );
140 }
141
142 public static function of(): ProductSearchResultBuilder
143 {
144 return new self();
145 }
146}
withMatchingVariantsBuilder(?ProductSearchMatchingVariantsBuilder $matchingVariants)
withMatchingVariants(?ProductSearchMatchingVariants $matchingVariants)