Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
76.19% |
16 / 21 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Uri | |
76.19% |
16 / 21 |
|
0.00% |
0 / 1 |
3.12 | |
0.00% |
0 / 1 |
| __construct | |
76.19% |
16 / 21 |
|
0.00% |
0 / 1 |
3.12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Zmsclient\Psr7; |
| 4 | |
| 5 | use Slim\Psr7\Factory\UriFactory; |
| 6 | |
| 7 | /** |
| 8 | * Layer to change PSR7 implementation if necessary |
| 9 | */ |
| 10 | class Uri extends \Slim\Psr7\Uri implements \Psr\Http\Message\UriInterface |
| 11 | { |
| 12 | public function __construct( |
| 13 | string $schemeOrUri = '', |
| 14 | ?string $host = null, |
| 15 | ?int $port = null, |
| 16 | string $path = '/', |
| 17 | string $query = '', |
| 18 | string $fragment = '', |
| 19 | string $user = '', |
| 20 | string $password = '' |
| 21 | ) { |
| 22 | if ($host !== null) { |
| 23 | parent::__construct($schemeOrUri, $host, $port, $path, $query, $fragment, $user, $password); |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | $temp = (new UriFactory())->createUri($schemeOrUri); |
| 28 | $userInfo = $temp->getUserInfo(); |
| 29 | $parsedUser = ''; |
| 30 | $parsedPassword = ''; |
| 31 | if ($userInfo !== '') { |
| 32 | $parts = explode(':', $userInfo, 2); |
| 33 | $parsedUser = $parts[0]; |
| 34 | $parsedPassword = $parts[1] ?? ''; |
| 35 | } |
| 36 | parent::__construct( |
| 37 | $temp->getScheme(), |
| 38 | $temp->getHost(), |
| 39 | $temp->getPort(), |
| 40 | $temp->getPath(), |
| 41 | $temp->getQuery(), |
| 42 | $temp->getFragment(), |
| 43 | $parsedUser, |
| 44 | $parsedPassword |
| 45 | ); |
| 46 | } |
| 47 | } |