Passed
Push — master ( da1b99...92df87 )
by Aleksandr
03:12
created

DomainModel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
c 0
b 0
f 0
dl 0
loc 34
ccs 17
cts 17
cp 1
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 6 2
A __construct() 0 4 1
A getName() 0 3 1
A setName() 0 4 1
A create() 0 4 1
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 * @author    Aleksandr Drobotik <[email protected]>
5
 * @copyright 2023 Aleksandr Drobotik
6
 * @license   https://opensource.org/license/mit  The MIT License
7
 */
8
declare(strict_types=1);
9
10
namespace Drobotik\Eav\Model;
11
12
use Drobotik\Eav\Enum\_DOMAIN;
13
14
class DomainModel extends Model
15
{
16
    private string $name;
17
18 1
    public function __construct()
19
    {
20 1
        $this->setTable(_DOMAIN::table());
21 1
        $this->setKeyName(_DOMAIN::ID->column());
22
    }
23
24 1
    public function getName(): string
25
    {
26 1
        return $this->name;
27
    }
28
29 1
    public function setName($name) : self
30
    {
31 1
        $this->name = $name;
32 1
        return $this;
33
    }
34
35 1
    public function create() : int
36
    {
37 1
        return $this->insert([
38 1
            _DOMAIN::NAME->column() => $this->getName()
39 1
        ]);
40
    }
41
42 1
    public function toArray(): array
43
    {
44 1
        $result = parent::toArray();
45 1
        if(isset($this->name))
46 1
            $result[_DOMAIN::NAME->column()] = $this->getName();
47 1
        return $result;
48
    }
49
50
51
}