Passed
Push — master ( f0d4c7...67a964 )
by Konrad
04:54
created

DefaultGraph::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
ccs 4
cts 4
cp 1
crap 2
1
<?php
2
3
namespace sweetrdf\InMemoryStoreSqlite\Rdf;
4
5
/*
6
 * This file is part of the sweetrdf/InMemoryStoreSqlite package and licensed under
7
 * the terms of the GPL-3 license.
8
 *
9
 * (c) Konrad Abicht <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
use rdfInterface\DefaultGraph as iDefaultGraph;
16
use rdfInterface\Term;
17
use rdfInterface\TYPE_DEFAULT_GRAPH;
0 ignored issues
show
Bug introduced by
The type rdfInterface\TYPE_DEFAULT_GRAPH 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...
18
use sweetrdf\InMemoryStoreSqlite\NamespaceHelper;
19
20
class DefaultGraph implements iDefaultGraph
21
{
22
    private ?string $iri;
23
24 2
    public function __construct(?string $iri = null)
25
    {
26 2
        if (empty($iri)) {
27 2
            $iri = NamespaceHelper::BASE_NAMESPACE;
28
        }
29
30 2
        $this->iri = $iri;
31 2
    }
32
33
    public function __toString(): string
34
    {
35
        return $this->getValue();
36
    }
37
38
    public function equals(Term $term): bool
39
    {
40
        return $this === $term;
41
    }
42
43
    public function getType(): string
44
    {
45
        return TYPE_DEFAULT_GRAPH;
46
    }
47
48
    public function getValue(): string
49
    {
50
        return $this->iri ?? TYPE_DEFAULT_GRAPH;
51
    }
52
}
53