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

StoreCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 35
ccs 6
cts 8
cp 0.75
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setDatabase() 0 3 1
A registerAppendix() 0 3 1
A registerColumn() 0 3 1
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