| Conditions | 1 |
| Paths | 1 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Tequilarapido\Cli\Commands\Base; |
||
| 28 | protected function setup() |
||
| 29 | { |
||
| 30 | // Database name |
||
| 31 | $this->databaseName = $this->config->getDatabaseName(); |
||
| 32 | |||
| 33 | // Database tables prefix |
||
| 34 | $this->databasePrefix = $this->config->getDatabasePrefix(); |
||
| 35 | |||
| 36 | // Golbal connection |
||
| 37 | $this->db = new Database(); |
||
| 38 | $dbConfig = $this->config->getDatabase(); |
||
| 39 | $this->db->connect($dbConfig); |
||
| 40 | } |
||
| 41 | |||
| 50 | } |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: