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 $productProjection;
36
41 private $matchingVariants;
42
49 public function getId()
50 {
51 return $this->id;
52 }
53
60 public function getProductProjection()
61 {
62 return $this->productProjection instanceof ProductProjectionBuilder ? $this->productProjection->build() : $this->productProjection;
63 }
64
71 public function getMatchingVariants()
72 {
73 return $this->matchingVariants instanceof ProductSearchMatchingVariantsBuilder ? $this->matchingVariants->build() : $this->matchingVariants;
74 }
75
80 public function withId(?string $id)
81 {
82 $this->id = $id;
83
84 return $this;
85 }
86
91 public function withProductProjection(?ProductProjection $productProjection)
92 {
93 $this->productProjection = $productProjection;
94
95 return $this;
96 }
97
102 public function withMatchingVariants(?ProductSearchMatchingVariants $matchingVariants)
103 {
104 $this->matchingVariants = $matchingVariants;
105
106 return $this;
107 }
108
113 public function withProductProjectionBuilder(?ProductProjectionBuilder $productProjection)
114 {
115 $this->productProjection = $productProjection;
116
117 return $this;
118 }
119
125 {
126 $this->matchingVariants = $matchingVariants;
127
128 return $this;
129 }
130
131 public function build(): ProductSearchResult
132 {
133 return new ProductSearchResultModel(
134 $this->id,
135 $this->productProjection instanceof ProductProjectionBuilder ? $this->productProjection->build() : $this->productProjection,
136 $this->matchingVariants instanceof ProductSearchMatchingVariantsBuilder ? $this->matchingVariants->build() : $this->matchingVariants
137 );
138 }
139
140 public static function of(): ProductSearchResultBuilder
141 {
142 return new self();
143 }
144}
withMatchingVariantsBuilder(?ProductSearchMatchingVariantsBuilder $matchingVariants)
withMatchingVariants(?ProductSearchMatchingVariants $matchingVariants)