From bbbf5cfc9dc46f58776954a18c0f60e342410a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Jo=C3=A1n=20Iglesias?= Date: Tue, 26 Jul 2016 02:14:57 -0400 Subject: [PATCH] For each body should be wrapped in an if statement (#14) unit test to go with commit --- src/Phpml/Math/Product.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Phpml/Math/Product.php b/src/Phpml/Math/Product.php index 70accb9..678dd71 100644 --- a/src/Phpml/Math/Product.php +++ b/src/Phpml/Math/Product.php @@ -16,7 +16,9 @@ class Product { $product = 0; foreach ($a as $index => $value) { - $product += $value * $b[$index]; + if (is_numeric($value) && is_numeric($b[$index])) { + $product += $value * $b[$index]; + } } return $product;