Conditions | 3 |
Paths | 3 |
Total Lines | 10 |
Code Lines | 6 |
Lines | 10 |
Ratio | 100 % |
Tests | 6 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
39 | 22 | View Code Duplication | public function toPsrUri($uri) |
|
|||
40 | { |
||
41 | 22 | if ($uri instanceof UriInterface) { |
|
42 | 7 | return $uri; |
|
43 | 22 | } elseif (is_string($uri)) { |
|
44 | 21 | return new Uri($uri); |
|
45 | } |
||
46 | |||
47 | 1 | throw new InvalidArgumentException('URI must be a string or an instance of \Psr\Http\Message\UriInterface.'); |
|
48 | } |
||
49 | } |
||
50 |
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.