• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thecodingmachine / dbal-fluid-schema-builder / 7686160655

28 Jan 2024 01:42PM UTC coverage: 100.0% (+0.6%) from 99.415%
7686160655

push

github

web-flow
Merge pull request #13 from aszenz/master

ci: Improve tests + fix ci deps

171 of 171 relevant lines covered (100.0%)

14.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/FluidColumnOptions.php
1
<?php
2

3

4
namespace TheCodingMachine\FluidSchema;
5

6
use Doctrine\DBAL\Schema\Column;
7
use Doctrine\DBAL\Types\Type;
8

9
class FluidColumnOptions
10
{
11
    /**
12
     * @var FluidTable
13
     */
14
    private $fluidTable;
15
    /**
16
     * @var Column
17
     */
18
    private $column;
19
    /**
20
     * @var NamingStrategyInterface
21
     */
22
    private $namingStrategy;
23

24
    /**
25
     * FluidColumn constructor.
26
     * @param FluidTable $fluidTable
27
     * @param Column $column
28
     */
29
    public function __construct(FluidTable $fluidTable, Column $column, NamingStrategyInterface $namingStrategy)
30
    {
31
        $this->fluidTable = $fluidTable;
48✔
32
        $this->column = $column;
48✔
33
        $this->namingStrategy = $namingStrategy;
48✔
34
    }
35

36
    /**
37
     * Makes the column not nullable.
38
     * @return FluidColumnOptions
39
     */
40
    public function notNull(): FluidColumnOptions
41
    {
42
        $this->column->setNotnull(true);
3✔
43
        return $this;
3✔
44
    }
45

46
    /**
47
     * Makes the column nullable.
48
     * @return FluidColumnOptions
49
     */
50
    public function null(): FluidColumnOptions
51
    {
52
        $this->column->setNotnull(false);
3✔
53
        return $this;
3✔
54
    }
55

56
    /**
57
     * Automatically add a unique constraint for the column.
58
     *
59
     * @return FluidColumnOptions
60
     */
61
    public function unique(): FluidColumnOptions
62
    {
63
        $this->column->setCustomSchemaOption('unique', true);
3✔
64
        return $this;
3✔
65
    }
66

67
    /**
68
     * Automatically add an index for the column.
69
     *
70
     * @return FluidColumnOptions
71
     */
72
    public function index(?string $indexName = null): FluidColumnOptions
73
    {
74
        $this->fluidTable->index([$this->namingStrategy->quoteIdentifier($this->column->getName())], $indexName);
3✔
75
        return $this;
3✔
76
    }
77
    public function comment(string $comment): FluidColumnOptions
78
    {
79
        $this->column->setComment($comment);
3✔
80
        return $this;
3✔
81
    }
82

83
    public function autoIncrement(): FluidColumnOptions
84
    {
85
        $this->column->setAutoincrement(true);
15✔
86
        return $this;
15✔
87
    }
88

89
    public function primaryKey(?string $indexName = null): FluidColumnOptions
90
    {
91
        $newIndexName = $indexName ?: false;
18✔
92

93
        $this->fluidTable->primaryKey([$this->namingStrategy->quoteIdentifier($this->column->getName())], $newIndexName);
18✔
94
        return $this;
18✔
95
    }
96

97
    public function default($defaultValue): FluidColumnOptions
98
    {
99
        $this->column->setDefault($defaultValue);
3✔
100
        return $this;
3✔
101
    }
102

103
    public function then(): FluidTable
104
    {
105
        return $this->fluidTable;
15✔
106
    }
107

108
    public function column($name): FluidColumn
109
    {
110
        return $this->fluidTable->column($name);
3✔
111
    }
112
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc