commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ReferenceFieldBuilder.php
1 <?php
2 
3 declare(strict_types=1);
10 
18 use stdClass;
19 
23 final class ReferenceFieldBuilder implements Builder
24 {
29  private $value;
30 
37  public function getValue()
38  {
39  return $this->value instanceof KeyReferenceBuilder ? $this->value->build() : $this->value;
40  }
41 
46  public function withValue(?KeyReference $value)
47  {
48  $this->value = $value;
49 
50  return $this;
51  }
52 
57  public function withValueBuilder(?KeyReferenceBuilder $value)
58  {
59  $this->value = $value;
60 
61  return $this;
62  }
63 
64  public function build(): ReferenceField
65  {
66  return new ReferenceFieldModel(
67  $this->value instanceof KeyReferenceBuilder ? $this->value->build() : $this->value
68  );
69  }
70 
71  public static function of(): ReferenceFieldBuilder
72  {
73  return new self();
74  }
75 }