From 9e35faece2dcc1497528cc0d7ae7b908a8d9e521 Mon Sep 17 00:00:00 2001 From: Patrick Henninger Date: Sun, 12 May 2019 17:23:14 +0200 Subject: [PATCH] Add validation and exception for weight to CartItem Constructor --- src/CartItem.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CartItem.php b/src/CartItem.php index 0717ed7..e5ac8ac 100644 --- a/src/CartItem.php +++ b/src/CartItem.php @@ -97,6 +97,9 @@ class CartItem implements Arrayable, Jsonable if (strlen($price) < 0 || !is_numeric($price)) { throw new \InvalidArgumentException('Please supply a valid price.'); } + if (strlen($weight) < 0 || !is_numeric($weight)) { + throw new \InvalidArgumentException('Please supply a valid weight.'); + } $this->id = $id; $this->name = $name;