33 namespace UriManage ;
44
55 use InvalidArgumentException ;
6- use Stringable ;
76 use Psr \Http \Message \UriInterface ;
7+ use Stringable ;
88 use UriManage \Actions \Compose ;
9+ use UriManage \Actions \Parse ;
910 use UriManage \Components \Path ;
1011 use UriManage \Components \Query ;
1112 use UriManage \Constants \Component ;
13+ use UriManage \Constants \DefaultSchemePorts ;
1214 use UriManage \Exceptions \UriException ;
1315
1416 class Uri implements UriInterface {
@@ -43,9 +45,9 @@ function __construct (string|Stringable|null $uri) {
4345 foreach ($ uriComponents as $ component => $ value ) {
4446 /** @psalm-suppress InvalidScalarArgument TODO: Remove when psalm supports `ArrayShape` attribute */
4547 match ($ component ) {
46- Component::HOST => $ this ->host = UriParser ::parseHost ($ value ),
47- Component::PATH => $ this ->path = UriParser ::parsePath ($ value ),
48- Component::QUERY => $ this ->query = UriParser ::parseQuery ($ value ),
48+ Component::HOST => $ this ->host = Parse ::parseHost ($ value ),
49+ Component::PATH => $ this ->path = Parse ::parsePath ($ value ),
50+ Component::QUERY => $ this ->query = Parse ::parseQuery ($ value ),
4951 default => $ this ->$ component = $ value
5052 };
5153 }
@@ -160,7 +162,7 @@ function withQuery ($query) : static {
160162 }
161163
162164 $ instance = clone $ this ;
163- $ instance ->query = ($ query === '' ) ? null : (($ query instanceof Query) ? $ query : UriParser ::parseQuery ($ query ));
165+ $ instance ->query = ($ query === '' ) ? null : (($ query instanceof Query) ? $ query : Parse ::parseQuery ($ query ));
164166
165167 return $ instance ;
166168 }
@@ -182,7 +184,7 @@ function withHost ($host) : static {
182184 if ($ host === '' ) {
183185 $ instance ->host = null ;
184186 } else {
185- $ instance ->host = UriParser ::parseHost ($ host );
187+ $ instance ->host = Parse ::parseHost ($ host );
186188 }
187189
188190 return $ instance ;
@@ -200,7 +202,7 @@ function withPath ($path) : static {
200202 }
201203
202204 $ instance = clone $ this ;
203- $ instance ->path = ($ path instanceof Path) ? $ path : UriParser ::parsePath ($ path );
205+ $ instance ->path = ($ path instanceof Path) ? $ path : Parse ::parsePath ($ path );
204206
205207 return $ instance ;
206208 }
0 commit comments