function __construct(string $code, int $price) { $this->code = $code; $this->price = $price; } public function price(): int { return $this->price; } } QSJWBUF
public function __construct(int $price) { $this->price = $price; } public function add(self $price): self { return new self($this->price + $price->price); } public function withTax(): self { return new self((int)($this->price * static::TAX_RATE)); } public function toInt(): int { return $this->price; } }
function __construct(string $code, int $price) { $this->code = $code; $this->price = new Price($price); } public function price(): Price { return $this->price; } }