Passed
Branch extract-store (f24e42)
by Konrad
04:37
created

BlankNode::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 1
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\BlankNode as iBlankNode;
16
use rdfInterface\Term;
17
use rdfInterface\TYPE_BLANK_NODE;
0 ignored issues
show
Bug introduced by
The type rdfInterface\TYPE_BLANK_NODE 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
19
class BlankNode implements iBlankNode
20
{
21
    private string $id;
22
23
    public function __construct(?string $id = null)
24
    {
25
        if (empty($id)) {
26
            // if no ID was given, generate random unique string
27
            $id = bin2hex(random_bytes(16));
28
        }
29
30
        if (!str_starts_with($id, '_:')) {
31
            $id = '_:'.$id;
32
        }
33
34
        $this->id = $id;
35
    }
36
37
    public function __toString(): string
38
    {
39
        return $this->id;
40
    }
41
42
    public function equals(Term $term): bool
43
    {
44
        return $this === $term;
45
    }
46
47
    public function getType(): string
48
    {
49
        return TYPE_BLANK_NODE;
50
    }
51
52
    public function getValue(): string
53
    {
54
        return $this->id;
55
    }
56
}
57