| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 26 | public function onDispatch(MvcEvent $e) |
||
| 27 | { |
||
| 28 | if (!$e->getRequest() instanceof ConsoleRequest) { |
||
|
|
|||
| 29 | throw new RuntimeException('You can only use this action from a console!'); |
||
| 30 | } |
||
| 31 | |||
| 32 | $table = new Ddl\CreateTable(Version::TABLE_NAME); |
||
| 33 | $table->addColumn(new Ddl\Column\Integer('id', false, null, ['autoincrement' => true])); |
||
| 34 | $table->addColumn(new Ddl\Column\BigInteger('version')); |
||
| 35 | $table->addConstraint(new Ddl\Constraint\PrimaryKey('id')); |
||
| 36 | $table->addConstraint(new Ddl\Constraint\UniqueKey('version')); |
||
| 37 | |||
| 38 | $sql = new Sql($this->dbAdapter); |
||
| 39 | |||
| 40 | try { |
||
| 41 | $this->dbAdapter->query($sql->buildSqlString($table), DbAdapter::QUERY_MODE_EXECUTE); |
||
| 42 | } catch (\Exception $e) { |
||
| 43 | // currently there are no db-independent way to check if table exists |
||
| 44 | // so we assume that table exists when we catch exception |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 48 |
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: