Skip to content

Commit c0c1a82

Browse files
committed
change
1 parent 2f0f4c9 commit c0c1a82

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

Diff for: src/sale/Sale.php

+4-24
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ class Sale implements SaleInterface
5353

5454
protected ?DateTimeImmutable $closeTime = null;
5555

56-
protected ?string $data = null;
56+
protected ?array $data = null;
5757

5858
public function __construct(
5959
$id,
6060
TargetInterface $target,
6161
CustomerInterface $customer,
6262
?PlanInterface $plan = null,
6363
?DateTimeImmutable $time = null,
64-
$data = null,
64+
?array $data = null,
6565
) {
6666
$this->id = $id;
6767
$this->target = $target;
6868
$this->customer = $customer;
6969
$this->plan = $plan;
7070
$this->time = $time ?? new DateTimeImmutable();
71-
$this->data = $this->setData($data);
71+
$this->data = $data;
7272
}
7373

7474
public function getId()
@@ -130,29 +130,9 @@ public function setId($id)
130130
$this->id = $id;
131131
}
132132

133-
public function setData($data): self
134-
{
135-
if (empty($data)) {
136-
$this->data = null;
137-
return $this;
138-
}
139-
140-
if (is_string($data) && json_validate($data)) {
141-
$this->data = $data;
142-
return $this;
143-
}
144-
145-
if (is_array($data)) {
146-
$this->data = Json::encode($data);
147-
return $this;
148-
}
149-
150-
throw new \Exception("Cannot assign data");
151-
}
152-
153133
public function getData(): ?array
154134
{
155-
return !empty($this->data) ? Json::decode($this->data, true) : null;
135+
return !empty($this->data) ? $this->data : null;
156136
}
157137

158138
public function jsonSerialize(): array

0 commit comments

Comments
 (0)