DomainModel   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 22
ccs 13
cts 13
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 1
A __construct() 0 4 1
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 * @author    Alex Kuperwood <[email protected]>
5
 * @copyright 2025 Alex Kuperwood
6
 * @license   https://opensource.org/license/mit  The MIT License
7
 */
8
declare(strict_types=1);
9
10
namespace Kuperwood\Eav\Model;
11
12
use Kuperwood\Eav\Enum\_DOMAIN;
13
14
class DomainModel extends Model
15
{
16
    public function __construct()
17 1
    {
18
        $this->setTable(_DOMAIN::table());
19 1
        $this->setPrimaryKey(_DOMAIN::ID);
20 1
    }
21
    /**
22
     * @throws Exception
23
     */
24
    public function create(array $data) : int
25 1
    {
26
        $conn = $this->db();
27 1
        $sql = sprintf(
28 1
            "INSERT INTO %s (%s) VALUES (:name)",
29 1
            _DOMAIN::table(),
30 1
            _DOMAIN::NAME
31 1
        );
32 1
        $stmt = $conn->prepare($sql);
33 1
        $stmt->bindParam(':name', $data[_DOMAIN::NAME]);
34 1
        $stmt->execute();
35 1
        return (int) $conn->lastInsertId();
36 1
    }
37
38
}