Passed
Push — dbal ( fbb214...fb7505 )
by Greg
06:03
created

Column   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 54
c 1
b 0
f 0
dl 0
loc 74
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fixed() 0 15 1
A autoincrement() 0 15 1
A default() 0 15 1
A nullable() 0 15 1
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2023 webtrees development team
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\DB;
21
22
use Doctrine\DBAL\ParameterType;
23
use Doctrine\DBAL\Platforms\AbstractPlatform;
0 ignored issues
show
Bug introduced by
The type Doctrine\DBAL\Platforms\AbstractPlatform 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...
24
use Doctrine\DBAL\Schema\Column as BaseColumn;
25
use Doctrine\DBAL\Types\StringType;
26
use Illuminate\Database\Capsule\Manager as DB;
27
28
/**
29
 * Fluent constructors for doctrine/dbal columns.
30
 */
31
class Column extends BaseColumn
32
{
33
    public function autoincrement(): static
34
    {
35
        return new static(
36
            name: $this->getName(),
37
            type: $this->getType(),
38
            options: [
39
                'length'          => $this->getLength(),
40
                'precision'       => $this->getPrecision(),
41
                'scale'           => $this->getScale(),
42
                'unsigned'        => $this->getUnsigned(),
43
                'fixed'           => $this->getFixed(),
44
                'notnull'         => $this->getNotnull(),
45
                'default'         => $this->getDefault(),
46
                'autoincrement'   => true,
47
                'platformOptions' => $this->getPlatformOptions(),
48
            ],
49
        );
50
    }
51
52
    public function default(int|string $default): static
53
    {
54
        return new static(
55
            name: $this->getName(),
56
            type: $this->getType(),
57
            options: [
58
                'length'          => $this->getLength(),
59
                'precision'       => $this->getPrecision(),
60
                'scale'           => $this->getScale(),
61
                'unsigned'        => $this->getUnsigned(),
62
                'fixed'           => $this->getFixed(),
63
                'notnull'         => $this->getNotnull(),
64
                'default'         => $default,
65
                'autoincrement'   => $this->getAutoincrement(),
66
                'platformOptions' => $this->getPlatformOptions(),
67
            ],
68
        );
69
    }
70
71
    public function fixed(): static
72
    {
73
        return new static(
74
            name: $this->getName(),
75
            type: $this->getType(),
76
            options: [
77
                'length'          => $this->getLength(),
78
                'precision'       => $this->getPrecision(),
79
                'scale'           => $this->getScale(),
80
                'unsigned'        => $this->getUnsigned(),
81
                'fixed'           => true,
82
                'notnull'         => $this->getNotnull(),
83
                'default'         => $this->getDefault(),
84
                'autoincrement'   => $this->getAutoincrement(),
85
                'platformOptions' => $this->getPlatformOptions(),
86
            ],
87
        );
88
    }
89
90
    public function nullable(): static
91
    {
92
        return new static(
93
            name: $this->getName(),
94
            type: $this->getType(),
95
            options: [
96
                'length'          => $this->getLength(),
97
                'precision'       => $this->getPrecision(),
98
                'scale'           => $this->getScale(),
99
                'unsigned'        => $this->getUnsigned(),
100
                'fixed'           => $this->getFixed(),
101
                'notnull'         => false,
102
                'default'         => $this->getDefault(),
103
                'autoincrement'   => $this->getAutoincrement(),
104
                'platformOptions' => $this->getPlatformOptions(),
105
            ],
106
        );
107
    }
108
}
109