Passed
Push — 2.x ( 0b5227...cb81b7 )
by butschster
16:17
created

StoreCommand::registerAppendix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\ORM\Command;
6
7
use Cycle\ORM\Heap\State;
8
use Cycle\Database\DatabaseInterface;
9
10
abstract class StoreCommand extends DatabaseCommand implements StoreCommandInterface
11
{
12
    protected array $columns = [];
13
14
    protected array $appendix = [];
15
16 2424
    public function __construct(
17
        DatabaseInterface $db,
18
        ?string $table,
19
        protected State $state
20
    ) {
21 2424
        parent::__construct($db, $table);
22
    }
23
24
    /**
25
     * @return array<string, mixed> Where Keys are DB filed names
26
     */
27
    abstract public function getStoreData(): array;
28
29 106
    public function registerColumn(string $key, mixed $value): void
30
    {
31 106
        $this->columns[$key] = $value;
32
    }
33
34 190
    public function registerAppendix(string $key, mixed $value): void
35
    {
36 190
        $this->appendix[$key] = $value;
37
    }
38
39
    /**
40
     * @internal
41
     */
42
    public function setDatabase(?DatabaseInterface $db): void
43
    {
44
        $this->db = $db;
45
    }
46
}
47