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.

Manipulation   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 23
Bugs 6 Features 9
Metric Value
wmc 17
c 23
b 6
f 9
lcom 0
cbo 1
dl 0
loc 109
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 6 1
A drop() 0 9 2
A clearDatabase() 0 6 1
A execute() 0 6 1
C getCommand() 0 28 11
1
<?php
2
3
namespace Rentgen\Schema;
4
5
use Symfony\Component\DependencyInjection\ContainerInterface;
6
7
use Rentgen\Rentgen;
8
use Rentgen\Database\Column;
9
use Rentgen\Database\Constraint\ConstraintInterface;
10
use Rentgen\Database\DatabaseObjectInterface;
11
use Rentgen\Database\Index;
12
use Rentgen\Database\Schema;
13
use Rentgen\Database\Table;
14
15
class Manipulation
16
{
17
    private $container;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param Symfony\Component\DependencyInjection\ContainerInterface $container
23
     */
24
    public function __construct(ContainerInterface $container)
25
    {
26
        $this->container = $container;
27
    }
28
29
    /**
30
     * Create a new database object.
31
     *
32
     * @param DatabaseObjectInterface $databaseObject Database object.
33
     *
34
     * @return integer
35
     */
36
    public function create(DatabaseObjectInterface $databaseObject)
37
    {
38
        $command = $this->getCommand($databaseObject);
39
40
        return $command->execute();
41
    }
42
43
    /**
44
     * Drop a database object.
45
     *
46
     * @param DatabaseObjectInterface $databaseObject Database object.
47
     * @param bool                    $cascade        Drop databse object cascade.
48
     *
49
     * @return integer
50
     */
51
    public function drop(DatabaseObjectInterface $databaseObject, $cascade = false)
52
    {
53
        $command = $this->getCommand($databaseObject, false);
54
        if ($cascade) {
55
            $command->cascade();
56
        }
57
58
        return $command->execute();
59
    }
60
61
    /**
62
     * Clear current database. Turn database to default state - empty public schema.
63
     *
64
     * @return integer
65
     */
66
    public function clearDatabase()
67
    {
68
        $clearDatabaseCommand = $this->container->get('rentgen.clear_database');
69
70
        return $clearDatabaseCommand->execute();
71
    }
72
73
    /**
74
     * Execute SQL query.
75
     *
76
     * @param string $sql Sql query.
77
     *
78
     * @return integer
79
     */
80
    public function execute($sql)
81
    {
82
        return $this->container
83
            ->get('connection')
84
            ->execute($sql);
85
    }
86
87
    /**
88
     * Get a command to execute.
89
     *
90
     * @param DatabaseObjectInterface $databaseObject Database object.
91
     * @param bool                    $cascade        Drop databse object cascade.
0 ignored issues
show
Bug introduced by
There is no parameter named $cascade. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
92
     *
93
     * @return Rentgen\Schema\Command
94
     */
95
    private function getCommand(DatabaseObjectInterface $databaseObject, $isCreate = true)
96
    {
97
        if ($databaseObject instanceof Column) {
98
           $command = $this->container
99
                ->get($isCreate ? 'rentgen.add_column' : 'rentgen.drop_column')
100
                ->setColumn($databaseObject);
101
        } elseif ($databaseObject instanceof ConstraintInterface) {
102
            $command = $this->container
103
                ->get($isCreate ? 'rentgen.add_constraint' : 'rentgen.drop_constraint')
104
                ->setConstraint($databaseObject);
105
        } elseif ($databaseObject instanceof Index) {
106
            $command = $this->container
107
                ->get($isCreate ? 'rentgen.create_index' : 'rentgen.drop_index')
108
                ->setIndex($databaseObject);
109
        } elseif ($databaseObject instanceof Schema) {
110
           $command = $this->container
111
                ->get($isCreate ? 'rentgen.create_schema' : 'rentgen.drop_schema')
112
                ->setSchema($databaseObject);
113
        } elseif ($databaseObject instanceof Table) {
114
            $command = $this->container
115
                ->get($isCreate ? 'rentgen.create_table' : 'rentgen.drop_table')
116
                ->setTable($databaseObject);
117
        } else {
118
            throw new \Exception(sprintf("Class %s is not supported", get_class($databaseObject)));
119
        }
120
121
        return $command;
122
    }
123
}
124