Test Failed
Push — master ( 492ea4...9c8472 )
by Bingo
04:47
created

SimpleWeightedGraph   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createBuilder() 0 6 2
A __construct() 0 11 1
1
<?php
2
3
namespace Graphp\Graph\Types;
4
5
use Graphp\Graph\Builder\GraphBuilder;
6
use Graphp\Util\SupplierUtil;
7
use Graphp\Util\SupplierInterface;
8
9
/**
10
 * Class SimpleWeightedGraph
11
 *
12
 * @package Graphp\Graph\Types
13
 */
14
class SimpleWeightedGraph extends SimpleGraph
15
{
16
    /**
17
     * Create a new simple graph
18
     *
19
     * @param string $edgeClass - the edge class
20
     * @param SupplierInterface $vertexSupplier - the vertex supplier
21
     * @param SupplierInterface $edgeSupplier - the edge supplier
22
     * @param bool $weighted - if the graph is weighted
23
     */
24
    public function __construct(
25 1
        ?string $edgeClass = null,
26
        ?SupplierInterface $vertexSupplier = null,
27
        ?SupplierInterface $edgeSupplier = null,
28
        ?bool $weighted = null
29
    ) {
30
        parent::__construct(
31 1
            $edgeClass,
32 1
            $vertexSupplier,
33 1
            $edgeSupplier,
34 1
            true
35 1
        );
36
    }
37 1
38
    /**
39
     * Create a simple graph builder
40
     *
41
     * @param string $edgeClass - the edge class
42
     * @param SupplierInterface $edgeSupplier - the edge supplier
43
     *
44
     * @return GraphBuilder
45
     */
46
    public function createBuilder(?string $edgeClass = null, ?SupplierInterface $edgeSupplier = null): GraphBuilder
47
    {
48
        if (!is_null($edgeClass)) {
49
            return new GraphBuilder(new SimpleWeightedGraph($edgeClass));
50
        }
51
        return new GraphBuilder(new SimpleWeightedGraph(null, $edgeSupplier));
52
    }
53
}
54