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 BadMethodCallException; |
16
|
|
|
use Exception; |
17
|
|
|
use rdfInterface\BlankNode as iBlankNode; |
18
|
|
|
use rdfInterface\DefaultGraph as iDefaultGraph; |
19
|
|
|
use rdfInterface\Literal as iLiteral; |
20
|
|
|
use rdfInterface\NamedNode as iNamedNode; |
21
|
|
|
use rdfInterface\Quad as iQuad; |
22
|
|
|
use rdfInterface\Term as iTerm; |
23
|
|
|
|
24
|
|
|
class Quad implements iQuad |
25
|
|
|
{ |
26
|
|
|
private iTerm $subject; |
27
|
|
|
|
28
|
|
|
private iNamedNode $predicate; |
29
|
|
|
|
30
|
|
|
private iTerm $object; |
31
|
|
|
|
32
|
|
|
private iNamedNode | iBlankNode | iDefaultGraph | null $graphIri; |
|
|
|
|
33
|
|
|
|
34
|
2 |
|
public function __construct( |
35
|
|
|
iTerm $subject, |
36
|
|
|
iNamedNode $predicate, |
37
|
|
|
iTerm $object, |
38
|
|
|
iNamedNode | iBlankNode | iDefaultGraph | null $graphIri = null |
39
|
|
|
) { |
40
|
2 |
|
if ($subject instanceof iLiteral) { |
41
|
1 |
|
throw new BadMethodCallException('Subject must be of type NamedNode or BlankNode'); |
42
|
|
|
} |
43
|
2 |
|
$this->subject = $subject; |
44
|
2 |
|
$this->predicate = $predicate; |
45
|
2 |
|
$this->object = $object; |
46
|
2 |
|
$this->graphIri = $graphIri ?? new DefaultGraph(); |
47
|
2 |
|
} |
48
|
|
|
|
49
|
|
|
public function __toString(): string |
50
|
|
|
{ |
51
|
|
|
return rtrim("$this->subject $this->predicate $this->object $this->graphIri"); |
52
|
|
|
} |
53
|
|
|
|
54
|
1 |
|
public function getType(): string |
55
|
|
|
{ |
56
|
1 |
|
return \rdfInterface\TYPE_QUAD; |
57
|
|
|
} |
58
|
|
|
|
59
|
1 |
|
public function equals(iTerm $term): bool |
60
|
|
|
{ |
61
|
1 |
|
return $this == $term; |
62
|
|
|
} |
63
|
|
|
|
64
|
1 |
|
public function getValue(): string |
65
|
|
|
{ |
66
|
1 |
|
throw new BadMethodCallException(); |
67
|
|
|
} |
68
|
|
|
|
69
|
1 |
|
public function getSubject(): iTerm |
70
|
|
|
{ |
71
|
1 |
|
return $this->subject; |
72
|
|
|
} |
73
|
|
|
|
74
|
1 |
|
public function getPredicate(): iNamedNode |
75
|
|
|
{ |
76
|
1 |
|
return $this->predicate; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function getObject(): iTerm |
80
|
|
|
{ |
81
|
|
|
return $this->object; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getGraphIri(): iNamedNode | iBlankNode |
85
|
|
|
{ |
86
|
|
|
return $this->graphIri; |
|
|
|
|
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public static function createFromArray(array $triple, string $graph): iQuad |
90
|
|
|
{ |
91
|
|
|
/* |
92
|
|
|
* subject |
93
|
|
|
*/ |
94
|
|
|
if ('uri' == $triple['s_type']) { |
95
|
|
|
$s = new NamedNode($triple['s']); |
96
|
|
|
} elseif ('bnode' == $triple['s_type']) { |
97
|
|
|
$s = new BlankNode($triple['s']); |
98
|
|
|
} else { |
99
|
|
|
throw new Exception('Invalid subject type given.'); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
// predicate |
103
|
|
|
$p = new NamedNode($triple['p']); |
104
|
|
|
|
105
|
|
|
/* |
106
|
|
|
* object |
107
|
|
|
*/ |
108
|
|
|
if ('uri' == $triple['o_type']) { |
109
|
|
|
$o = new NamedNode($triple['o']); |
110
|
|
|
} elseif ('bnode' == $triple['o_type']) { |
111
|
|
|
$o = new BlankNode($triple['o']); |
112
|
|
|
} elseif ('literal' == $triple['o_type']) { |
113
|
|
|
$o = new Literal($triple['o'], $triple['o_lang'], $triple['o_datatype']); |
114
|
|
|
} else { |
115
|
|
|
throw new Exception('Invalid object type given.'); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
$g = !empty($graph) ? new NamedNode($graph) : new DefaultGraph(); |
119
|
|
|
|
120
|
|
|
return new self($s, $p, $o, $g); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function withSubject(iTerm $subject): iQuad |
124
|
|
|
{ |
125
|
|
|
throw new Exception('withSubject not implemented yet.'); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function withPredicate(iNamedNode $predicate): iQuad |
129
|
|
|
{ |
130
|
|
|
throw new Exception('withPredicate not implemented yet.'); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function withObject(iTerm $object): iQuad |
134
|
|
|
{ |
135
|
|
|
throw new Exception('withObject not implemented yet.'); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function withGraphIri( |
139
|
|
|
iNamedNode | iBlankNode | iDefaultGraph | null $graphIri |
140
|
|
|
): iQuad { |
141
|
|
|
throw new Exception('withGraphIri not implemented yet.'); |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths