commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ReplicaMyCartDraftModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
19 use stdClass;
20 
25 {
30  protected $reference;
31 
32 
36  public function __construct(
37  ?JsonObject $reference = null
38  ) {
39  $this->reference = $reference;
40  }
41 
48  public function getReference()
49  {
50  if (is_null($this->reference)) {
52  $data = $this->raw(self::FIELD_REFERENCE);
53  if (is_null($data)) {
54  return null;
55  }
56  $this->reference = $data;
57  }
58 
59  return $this->reference;
60  }
61 
67  public function getReferenceAsCartReference()
68  {
70  $data = $this->raw(self::FIELD_REFERENCE);
71  if (is_null($data)) {
72  return null;
73  }
74 
75  return CartReferenceModel::of($data);
76  }
77 
83  public function getReferenceAsOrderReference()
84  {
86  $data = $this->raw(self::FIELD_REFERENCE);
87  if (is_null($data)) {
88  return null;
89  }
90 
91  return OrderReferenceModel::of($data);
92  }
93 
97  public function setReference(?JsonObject $reference): void
98  {
99  $this->reference = $reference;
100  }
101 }