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

DefaultGraph   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
dl 0
loc 31
ccs 0
cts 12
cp 0
rs 10
c 1
b 0
f 1
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A equals() 0 3 1
A __construct() 0 7 2
A __toString() 0 3 1
A getType() 0 3 1
A getValue() 0 3 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\DefaultGraph;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, sweetrdf\InMemoryStoreSqlite\Rdf\DefaultGraph. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
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
0 ignored issues
show
Bug introduced by
The type sweetrdf\InMemoryStoreSqlite\Rdf\iDefaultGraph 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...
21
{
22
    private ?string $iri;
23
24
    public function __construct(?string $iri = null)
25
    {
26
        if (empty($iri)) {
27
            $iri = NamespaceHelper::BASE_NAMESPACE;
28
        }
29
30
        $this->iri = $iri;
31
    }
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