VectorValue   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 1
cbo 1
dl 0
loc 37
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getValue() 0 4 1
A scalar() 0 9 2
1
<?php
2
namespace MachineLearning\Domain\Model\Value;
3
use MachineLearning\Domain\Model\ValueInterface;
4
5
class VectorValue implements ValueInterface
6
{
7
    /**
8
     * @var float[]
9
     */
10
    protected $value;
11
12
    /**
13
     * @param float[]|array<integer,array> $value
14
     */
15 4
    public function __construct($value)
16
    {
17 4
        $this->value = $value;
0 ignored issues
show
Documentation Bug introduced by
It seems like $value of type array<integer,double|array> is incompatible with the declared type array<integer,double> of property $value.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
18 4
    }
19
20
    /**
21
     * @return \float[]
22
     */
23 4
    public function getValue()
24
    {
25 4
        return $this->value;
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31 2
    public function scalar(ValueInterface $value)
32
    {
33 2
        $result = 0;
34 2
        $columns = count($this->value);
35 2
        for ($i=0; $i<$columns; $i++) {
36 2
            $result += $this->value[$i]*$value->getValue()[$i];
37 2
        }
38 2
        return $result;
39
    }
40
41
}
42