Column::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 8
c 0
b 0
f 0
nc 1
nop 8
dl 0
loc 10
ccs 9
cts 9
cp 1
crap 1
rs 10

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace mindplay\sql\model\schema;
4
5
use mindplay\sql\model\Driver;
6
7
/**
8
 * This class represents a Column belonging to a Table.
9
 */
10
class Column
11
{
12
    private Table $table;
13
    private Driver $driver;
14
    private Type $type;
15
    private string $name;
16
    private string|null $alias;
17
    private bool $required;
18
    private mixed $default;
19
    private bool $auto;
20
21
    /**
22
     * @param $table parent Table instance
0 ignored issues
show
Bug introduced by
The type mindplay\sql\model\schema\parent 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...
23
     */
24 1
    public function __construct(Driver $driver, Table $table, string $name, Type $type, string|null $alias, bool $required, mixed $default, bool $auto)
25
    {
26 1
        $this->table = $table;
27 1
        $this->driver = $driver;
28 1
        $this->type = $type;
29 1
        $this->name = $name;
30 1
        $this->alias = $alias;
31 1
        $this->required = $required;
32 1
        $this->default = $default;
33 1
        $this->auto = $auto;
34
    }
35
36 1
    public function getTable(): Table
37
    {
38 1
        return $this->table;
39
    }
40
41 1
    public function getType(): Type
42
    {
43 1
        return $this->type;
44
    }
45
46 1
    public function getName(): string
47
    {
48 1
        return $this->name;
49
    }
50
51 1
    public function getAlias(): string|null
52
    {
53 1
        return $this->alias;
54
    }
55
56
    public function isRequired(): bool
57
    {
58
        return $this->required;
59
    }
60
61
    public function getDefault(): mixed
62
    {
63
        return $this->default;
64
    }
65
66 1
    public function isAuto(): bool
67
    {
68 1
        return $this->auto;
69
    }
70
71 1
    public function __toString(): string
72
    {
73 1
        return $this->table->__toString() . '.' . $this->driver->quoteName($this->name);
74
    }
75
}
76