DataSetHolder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace DataSource\TableDataGateway;
6
7
use DataSource\Connection;
8
use BasePatterns\RecordSet\RecordSet;
9
use Infrastructure\Database\DbDataAdapter;
10
11
class DataSetHolder
12
{
13
    public RecordSet $data;
14
15
    private array $dataAdapters = [];
16
17
    private Connection $connection;
18
19
    public function __construct(Connection $connection)
20
    {
21
        $this->connection = $connection;
22 3
        $this->data = new RecordSet();
23
    }
24 3
25 3
    public function fillData(
26 3
        string $query,
27
        string $tableName,
28 3
        array $params = []
0 ignored issues
show
Unused Code introduced by
The parameter $params is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

28
        /** @scrutinizer ignore-unused */ array $params = []

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    ): void {
30
        if (array_key_exists($tableName, $this->dataAdapters)) {
31
            throw new MultipleLoadException();
32
        }
33 3
        $da = new DbDataAdapter($query, $this->connection);
34
        $da->fill($this->data, $tableName);
35
        $this->dataAdapters[$tableName] = $da;
36 3
    }
37 3
38 3
    public function update(): void
39 3
    {
40
        foreach ($this->dataAdapters as $table => $da) {
41 1
            $da->update($this->data, $table);
42
        }
43 1
    }
44
}
45