Passed
Push — master ( 17e6cc...350d8b )
by Aleksandr
41:29 queued 06:24
created

DomainModel   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 22
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
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 Doctrine\DBAL\Exception;
0 ignored issues
show
Bug introduced by
The type Doctrine\DBAL\Exception was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Kuperwood\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->setPrimaryKey(_DOMAIN::ID);
21
    }
22
    /**
23
     * @throws Exception
24
     */
25 1
    public function create(array $data) : int
26
    {
27 1
        $conn = $this->db();
28 1
        $sql = sprintf(
29 1
            "INSERT INTO %s (%s) VALUES (:name)",
30 1
            _DOMAIN::table(),
31 1
            _DOMAIN::NAME
32 1
        );
33 1
        $stmt = $conn->prepare($sql);
34 1
        $stmt->bindParam(':name', $data[_DOMAIN::NAME]);
35 1
        $stmt->execute();
36 1
        return (int) $conn->lastInsertId();
37
    }
38
39
}