GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AddColumnCommand::setColumn()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Rentgen\Schema\Manipulation;
3
4
use Rentgen\Schema\Command;
5
use Rentgen\Database\Column;
6
use Rentgen\Database\Column\CustomColumn;
7
use Rentgen\Event\ColumnEvent;
8
use Rentgen\Schema\ColumnTypeMapper;
9
10
class AddColumnCommand extends Command
11
{
12
    private $column;
13
14
    /**
15
     * Sets a column.
16
     *
17
     * @param Column $column The column instance.
18
     *
19
     * @return AddColumnCommand
20
     */
21
    public function setColumn(Column $column)
22
    {
23
        $this->column = $column;
24
25
        return $this;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function getSql()
32
    {
33
        if ($this->column instanceof CustomColumn) {
34
            $columnType = $this->column->getType();
35
        } else {
36
            $columnTypeMapper = new ColumnTypeMapper();
37
            $columnType = $columnTypeMapper->getNative($this->column->getType());
38
        }
39
40
        $sql = sprintf('ALTER TABLE %s ADD COLUMN %s %s;'
41
            , $this->column->getTable()->getQualifiedName()
42
            , $this->column->getName()
43
            , $columnType
44
        );
45
46
        $columnDescription = $this->column->getDescription();
47
        if (!empty($tableDescription)) {
0 ignored issues
show
Bug introduced by
The variable $tableDescription seems to never exist, and therefore empty should always return true. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
48
            $sql .= sprintf("COMMENT ON COLUMN %s.%s IS '%s';",
49
                $this->column->getTable()->getQualifiedName(),
50
                $this->column->getName(),
51
                $columnDescription);
52
        }
53
54
        return $sql;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    protected function postExecute()
61
    {
62
        $this->dispatcher->dispatch('column.add', new ColumnEvent($this->column, $this->getSql()));
63
    }
64
}
65