Completed
Push — master ( 044c87...663c3d )
by Bingo
04:35
created

SimpleGraph::createBuilder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
dl 0
loc 6
ccs 0
cts 4
cp 0
rs 10
c 1
b 0
f 1
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
namespace graphp\graph\types;
4
5
use graphp\graph\AbstractGraph;
6
use graphp\graph\builder\GraphTypeBuilder;
7
use graphp\util\SupplierUtil;
8
9
/**
10
 * Class SimpleGraph
11
 *
12
 * @package graphp\graph\types
13
 */
14
class SimpleGraph extends AbstractGraph
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 6
    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 6
        $builder = new GraphTypeBuilder();
31 6
        $graphType = $builder->undirected()
32 6
                    ->allowSelfLoops(false)
33 6
                    ->allowMultipleEdges(false)
34 6
                    ->weighted($weighted)
35 6
                    ->build();
36 6
        if (!is_null($edgeClass)) {
37 6
            $util = new SupplierUtil();
38 6
            $edgeSupplier = $util->createSupplier($edgeClass);
39 6
            parent::__construct(
40 6
                $vertexSupplier,
41 6
                $edgeSupplier,
42 6
                $graphType
43
            );
44
        } else {
45
            parent::__construct(
46
                $vertexSupplier,
47
                $edgeSupplier,
48
                $graphType
49
            );
50
        }
51 6
    }
52
53
    /**
54
     * Create a simple graph builder
55
     *
56
     * @param string $edgeClass - the edge class
57
     * @param SupplierInterface $edgeSupplier - the edge supplier
58
     *
59
     * @return GraphBuilder
60
     */
61
    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...
62
    {
63
        if (!is_null($edgeClass)) {
64
            return new GraphBuilder(new SimpleGraph($edgeClass));
65
        }
66
        return new GraphBuilder(new SimpleGraph(null, $edgeSupplier));
67
    }
68
}
69