Constraint   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 41
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 4 1
A columnNames() 0 4 1
A getName() 0 3 1
A getColumnNames() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Constraint;
6
7
/**
8
 * Represents a constraint in a database.
9
 *
10
 * A constraint is a rule that's enforced on the data in a table, such as a primary key, a foreign key, a default value,
11
 * check or index constraint.
12
 *
13
 * It's the base class for all constraint classes, and defines methods that are common and shared by all constrained
14
 * classes, with name and columnNames being the most common ones.
15
 */
16
class Constraint
17 109
{
18
    private string|array|null $columnNames = null;
19 109
    private string|null|object $name = null;
20
21
    /**
22 162
     * @return array|string|null The list of column names the constraint belongs to.
23
     */
24 162
    public function getColumnNames(): array|string|null
25
    {
26
        return $this->columnNames;
27
    }
28
29
    /**
30
     * @return object|string|null The constraint name.
31
     */
32 323
    public function getName(): object|string|null
33
    {
34 323
        return $this->name;
35
    }
36 323
37
    /**
38
     * Set the list of column names the constraint belongs to.
39
     *
40
     * @param array|string|null $value The list of column names the constraint belongs to.
41
     */
42
    public function columnNames(array|string|null $value): static
43
    {
44 320
        $this->columnNames = $value;
45
        return $this;
46 320
    }
47
48 320
    /**
49
     * Set the constraint name.
50
     *
51
     * @param object|string|null $value The constraint name.
52
     */
53
    public function name(object|string|null $value): static
54
    {
55
        $this->name = $value;
56
        return $this;
57
    }
58
}
59