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.

AddConstraintCommand::setConstraint()   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\Constraint\ConstraintInterface;
6
use Rentgen\Database\Constraint\ForeignKey;
7
use Rentgen\Database\Constraint\Unique;
8
use Rentgen\Database\Table;
9
10
class AddConstraintCommand extends Command
11
{
12
    private $constraint;
13
14
    /**
15
     * Set a constraint.
16
     *
17
     * @param ConstraintInterface $constraint A constraint instance.
18
     *
19
     * @return AddConstraintCommand
20
     */
21
    public function setConstraint(ConstraintInterface $constraint)
22
    {
23
        $this->constraint = $constraint;
24
25
        return $this;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function getSql()
32
    {
33
        if ($this->constraint instanceof ForeignKey) {
34
            return sprintf('ALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s) MATCH SIMPLE ON UPDATE %s ON DELETE %s;'
35
                , $this->constraint->getTable()->getQualifiedName()
36
                , $this->constraint->getName()
37
                , implode(',', $this->constraint->getColumns())
38
                , $this->constraint->getReferencedTable()->getQualifiedName()
39
                , implode(',', $this->constraint->getReferencedColumns())
40
                , $this->constraint->getUpdateAction()
41
                , $this->constraint->getDeleteAction()
42
            );
43
        }
44
        if ($this->constraint instanceof Unique) {
45
            return sprintf('ALTER TABLE %s ADD CONSTRAINT %s UNIQUE (%s);'
46
                , $this->constraint->getTable()->getQualifiedName()
47
                , $this->constraint->getName()
48
                , implode(',', $this->constraint->getColumns())
49
            );
50
        }
51
    }
52
}
53