| Conditions | 3 |
| Paths | 3 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 12 |
| Ratio | 100 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 42 | 4 | final public function create($driver = self::DRIVER_FTP, $params = array()) |
|
| 43 | { |
||
| 44 | 4 | $class = $this->getClassNameForDriver($driver); |
|
| 45 | 4 | if (!class_exists($class)) { |
|
| 46 | 1 | throw new Exception('Unable to create ' . $class); |
|
| 47 | } |
||
| 48 | 3 | $instance = new $class($params); |
|
| 49 | 3 | if (!$instance instanceof FtpInterface) { |
|
| 50 | 1 | throw new Exception('Unable to create ' . $class); |
|
| 51 | } |
||
| 52 | 2 | return $instance; |
|
| 53 | } |
||
| 54 | |||
| 65 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.