WeightedEdgeSpecifics::setEdgeWeight()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Graphp\Edge\Specifics;
4
5
use Graphp\Edge\EdgeInterface;
6
use Graphp\Vertex\VertexInterface;
7
8
/**
9
 * Class WeightedEdgeSpecifics
10
 *
11
 * @package Graphp\Edge\Specifics
12
 */
13
class WeightedEdgeSpecifics extends UniformEdgeSpecifics
14
{
15
    /**
16
     * Get the edge weight
17
     *
18
     * @param EdgeInterface $edge - the edge
19
     *
20
     * @return null|float
21
     */
22 8
    public function getEdgeWeight(EdgeInterface $edge): ?float
23
    {
24 8
        return $edge->getWeight();
0 ignored issues
show
Bug introduced by
The method getWeight() does not exist on Graphp\Edge\EdgeInterface. It seems like you code against a sub-type of Graphp\Edge\EdgeInterface such as Graphp\Edge\DefaultWeightedEdge. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return $edge->/** @scrutinizer ignore-call */ getWeight();
Loading history...
25
    }
26
    
27
    /**
28
     * Set the edge weight
29
     *
30
     * @param EdgeInterface $edge - the edge
31
     * @param float $weight - the weight
32
     */
33 9
    public function setEdgeWeight(EdgeInterface $edge, ?float $weight = null): void
34
    {
35 9
        $edge->setWeight($weight);
0 ignored issues
show
Bug introduced by
The method setWeight() does not exist on Graphp\Edge\EdgeInterface. It seems like you code against a sub-type of Graphp\Edge\EdgeInterface such as Graphp\Edge\DefaultWeightedEdge. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        $edge->/** @scrutinizer ignore-call */ 
36
               setWeight($weight);
Loading history...
36 9
    }
37
}
38