Passed
Push — master ( cc5eb6...7e77a4 )
by Konrad
03:36
created

BaseParser::_getSimpleIndex()   F

Complexity

Conditions 29
Paths > 20000

Size

Total Lines 52
Code Lines 36

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 870

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 29
eloc 36
c 1
b 0
f 0
nc 131283
nop 3
dl 0
loc 52
ccs 0
cts 36
cp 0
crap 870
rs 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/*
4
 * This file is part of the sweetrdf/InMemoryStoreSqlite package and licensed under
5
 * the terms of the GPL-3 license.
6
 *
7
 * (c) Konrad Abicht <[email protected]>
8
 * (c) Benjamin Nowack
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace sweetrdf\InMemoryStoreSqlite\Parser;
15
16
use sweetrdf\InMemoryStoreSqlite\Log\Logger;
17
use sweetrdf\InMemoryStoreSqlite\NamespaceHelper;
18
use sweetrdf\InMemoryStoreSqlite\StringReader;
19
20
abstract class BaseParser
21
{
22
    /**
23
     * @var array
24
     */
25
    protected $added_triples;
26
27
    protected string $base;
28
29
    protected string $bnode_id;
30
31
    protected array $blocks;
32
33
    protected Logger $logger;
34
35
    protected NamespaceHelper $namespaceHelper;
36
37
    /**
38
     * Query infos container.
39
     */
40
    protected array $r = [];
41
42
    protected StringReader $stringReader;
43
44
    protected array $triples = [];
45
46
    protected int $t_count = 0;
47
48 98
    public function __construct(Logger $logger, NamespaceHelper $namespaceHelper, StringReader $stringReader)
49
    {
50 98
        $this->reader = $stringReader;
0 ignored issues
show
Bug Best Practice introduced by
The property reader does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
51
52 98
        $this->logger = $logger;
53
54 98
        $this->namespaceHelper = $namespaceHelper;
55
56
        // generates random prefix for blank nodes
57 98
        $this->bnode_prefix = bin2hex(random_bytes(4)).'b';
0 ignored issues
show
Bug Best Practice introduced by
The property bnode_prefix does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
58
59 98
        $this->bnode_id = 0;
60 98
    }
61
62 96
    public function getQueryInfos()
63
    {
64 96
        return $this->r;
65
    }
66
67 2
    public function getTriples()
68
    {
69 2
        return $this->triples;
70
    }
71
}
72