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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 43
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setConstraint() 0 6 1
A getSql() 0 21 3
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