WeightedPseudograph::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 3
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 WeightedPseudograph
11
 *
12
 * @package Graphp\Graph\Types
13
 */
14
class WeightedPseudograph extends Pseudograph
15
{
16
    /**
17
     * Create a new simple weighted pseudograph
18
     *
19
     * @param string $edgeClass - the edge class
20
     * @param SupplierInterface $vertexSupplier - the vertex supplier
21
     * @param SupplierInterface $edgeSupplier - the edge supplier
22
     */
23 1
    public function __construct(
24
        ?string $edgeClass = null,
25
        ?SupplierInterface $vertexSupplier = null,
26
        ?SupplierInterface $edgeSupplier = null
27
    ) {
28 1
        parent::__construct(
29 1
            $edgeClass,
30 1
            $vertexSupplier,
31 1
            $edgeSupplier,
32 1
            true
33
        );
34 1
    }
35
36
    /**
37
     * Create a simple directed weighted graph builder
38
     *
39
     * @param string $edgeClass - the edge class
40
     * @param SupplierInterface $edgeSupplier - the edge supplier
41
     *
42
     * @return GraphBuilder
43
     */
44
    public function createBuilder(?string $edgeClass = null, ?SupplierInterface $edgeSupplier = null): GraphBuilder
45
    {
46
        if (!is_null($edgeClass)) {
47
            return new GraphBuilder(new WeightedPseudograph($edgeClass));
48
        }
49
        return new GraphBuilder(new WeightedPseudograph(null, $edgeSupplier));
50
    }
51
}
52