Completed
Push — master ( d31b6a...3535ea )
by Bingo
04:00
created

DefaultDirectedGraph   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 23
c 0
b 0
f 0
dl 0
loc 54
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createBuilder() 0 6 2
A __construct() 0 26 2
1
<?php
2
3
namespace graphp\graph\types;
4
5
use graphp\graph\AbstractGraph;
6
use graphp\graph\GraphTypeBuilder;
7
use graphp\util\SupplierUtil;
8
9
/**
10
 * Class DefaultDirectedGraph
11
 *
12
 * @package graphp\graph\types
13
 */
14
class DefaultDirectedGraph extends AbstractGraph
15
{
16
    /**
17
     * Create a new default directed 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
        ?string $edgeClass = null,
26
        ?SupplierInterface $vertexSupplier = null,
0 ignored issues
show
Bug introduced by
The type graphp\graph\types\SupplierInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
        ?SupplierInterface $edgeSupplier = null,
28
        ?bool $weighted = null
29
    ) {
30
        $builder = new GraphTypeBuilder();
31
        $graphType = $builder->directed()
32
                    ->allowSelfLoops(true)
33
                    ->allowMultipleEdges(false)
34
                    ->allowCycles(false)
35
                    ->weighted($weighted)
36
                    ->build();
37
        if (!is_null($edgeClass)) {
38
            $util = new SupplierUtil();
39
            $edgeSupplier = $util->createSupplier($edgeClass);
40
            parent::__construct(
41
                $vertexSupplier,
42
                $edgeSupplier,
43
                $graphType
44
            );
45
        } else {
46
            parent::__construct(
47
                $vertexSupplier,
48
                $edgeSupplier,
49
                $graphType
50
            );
51
        }
52
    }
53
54
    /**
55
     * Create a default directed graph builder
56
     *
57
     * @param string $edgeClass - the edge class
58
     * @param SupplierInterface $edgeSupplier - the edge supplier
59
     *
60
     * @return GraphBuilder
61
     */
62
    public function createBuilder(?string $edgeClass = null, ?SupplierInterface $edgeSupplier = null): GraphBuilder
0 ignored issues
show
Bug introduced by
The type graphp\graph\types\GraphBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
63
    {
64
        if (!is_null($edgeClass)) {
65
            return new GraphBuilder(new DefaultDirectedGraph($edgeClass));
66
        }
67
        return new GraphBuilder(new DefaultDirectedGraph(null, $edgeSupplier));
68
    }
69
}
70