amphp / socket

Non-blocking socket and TLS functionality for PHP based on Amp.
https://amphp.org/socket
MIT License
237 stars 38 forks source link

Add InternetAddress::tryFromString() #105

Closed trowski closed 1 year ago

trowski commented 1 year ago

This PR adds InternetAddress::tryFromString(), which is similar to fromString(), accept it returns null instead of throwing.

Seems we were a bit inconsistent with throwing SocketException vs. ValueError for invalid portions of the address. I changed them all to SocketException. I think this should be fine, since we declared the constructor and fromString as throwing SocketException on an invalid address.