Conditions | 5 |
Paths | 7 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
43 | public function generate(Schema $schema) |
||
44 | { |
||
45 | if (!is_dir($this->inputPath)) { |
||
46 | throw new \RuntimeException('The input file path "' . $this->inputPath . '" is not a directory'); |
||
47 | } |
||
48 | |||
49 | $con = Rocket::getConnection($schema->connection); |
||
50 | if (!$con instanceof SQLitePDO) { |
||
51 | $con->exec('use ' . $schema->database); |
||
|
|||
52 | } |
||
53 | |||
54 | $file = file_get_contents($this->inputPath . DIRECTORY_SEPARATOR . $schema->database . '.sql'); |
||
55 | $file = preg_replace('/(-- ?(.)*)*/', '', $file); // delete comments |
||
56 | |||
57 | $queries = explode(';', $file); |
||
58 | foreach ($queries as $query) { |
||
59 | $query = trim($query); |
||
60 | if ('' == $query) { |
||
61 | continue; |
||
62 | } |
||
63 | |||
64 | $con->exec($query); |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: