From b30f4cbf11778d22a78d50754b80d68649bae5fb Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Thu, 21 Apr 2016 22:12:45 +0200 Subject: [PATCH] make scalar function static --- src/Phpml/Math/Product.php | 2 +- tests/Phpml/Math/ProductTest.php | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Phpml/Math/Product.php b/src/Phpml/Math/Product.php index 992eeaa..3772207 100644 --- a/src/Phpml/Math/Product.php +++ b/src/Phpml/Math/Product.php @@ -12,7 +12,7 @@ class Product * * @return mixed */ - public function scalar(array $a, array $b) + public static function scalar(array $a, array $b) { $product = 0; foreach ($a as $index => $value) { diff --git a/tests/Phpml/Math/ProductTest.php b/tests/Phpml/Math/ProductTest.php index d7aa015..ade9942 100644 --- a/tests/Phpml/Math/ProductTest.php +++ b/tests/Phpml/Math/ProductTest.php @@ -10,11 +10,9 @@ class ProductTest extends \PHPUnit_Framework_TestCase public function testScalarProduct() { - $product = new Product(); - - $this->assertEquals(10, $product->scalar([2, 3], [-1, 4])); - $this->assertEquals(-0.1, $product->scalar([1, 4, 1], [-2, 0.5, -0.1])); - $this->assertEquals(8, $product->scalar([2], [4])); + $this->assertEquals(10, Product::scalar([2, 3], [-1, 4])); + $this->assertEquals(-0.1, Product::scalar([1, 4, 1], [-2, 0.5, -0.1])); + $this->assertEquals(8, Product::scalar([2], [4])); } } \ No newline at end of file