Passed
Push — master ( 023570...3c9f2b )
by Aleksandr
02:49
created

DomainModel::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 2
rs 10
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 Doctrine\DBAL\Exception;
13
use Drobotik\Eav\Enum\_DOMAIN;
14
15
class DomainModel extends Model
16
{
17 1
    public function __construct()
18
    {
19 1
        $this->setTable(_DOMAIN::table());
20 1
        $this->setKeyName(_DOMAIN::ID->column());
21
    }
22
    /**
23
     * @throws Exception
24
     */
25 1
    public function create(array $data) : int
26
    {
27 1
        $conn = $this->db();
28 1
        $conn->createQueryBuilder()
29 1
            ->insert(_DOMAIN::table())
30 1
            ->values([
31 1
                _DOMAIN::NAME->column() => '?'
32 1
            ])
33 1
            ->setParameter(0, $data[_DOMAIN::NAME->column()])
34 1
            ->executeQuery();
35 1
        return (int) $conn->lastInsertId();
36
    }
37
38
}