File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -267,6 +267,10 @@ public function getPriceWithMinorUnits(): ?float
267267 */
268268 public function setPrice ($ price ): self
269269 {
270+ if (!is_int ($ price ) && !is_float ($ price ) && !is_null ($ price )) {
271+ throw new InvalidArgumentException ('Lead price must be an integer, float or null. ' );
272+ }
273+
270274 $ this ->price = $ price ;
271275
272276 return $ this ;
Original file line number Diff line number Diff line change @@ -183,6 +183,22 @@ public function testToApiOmitsPriceWhenItWasNotSet(): void
183183 $ this ->assertSame (['request_id ' => '0 ' ], (new LeadModel ())->toApi ());
184184 }
185185
186+ public function testSetPriceWithStringThrowsException (): void
187+ {
188+ $ this ->expectException (InvalidArgumentException::class);
189+ $ this ->expectExceptionMessage ('Lead price must be an integer, float or null. ' );
190+
191+ (new LeadModel ())->setPrice ('100.0 ' );
192+ }
193+
194+ public function testSetPriceWithArrayThrowsException (): void
195+ {
196+ $ this ->expectException (InvalidArgumentException::class);
197+ $ this ->expectExceptionMessage ('Lead price must be an integer, float or null. ' );
198+
199+ (new LeadModel ())->setPrice ([100 ]);
200+ }
201+
186202 private function assertPriceState (LeadModel $ lead , ?int $ legacyPrice , ?float $ priceWithMinorUnits ): void
187203 {
188204 $ this ->assertSame ($ legacyPrice , $ lead ->getPrice ());
You can’t perform that action at this time.
0 commit comments