make scalar function static

This commit is contained in:
Arkadiusz Kondas 2016-04-21 22:12:45 +02:00
parent 34281e40ee
commit b30f4cbf11
2 changed files with 4 additions and 6 deletions

View File

@ -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) {

View File

@ -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]));
}
}