ytake/valueobjects

Include negative and edge cases testing and validation

bizmate opened this issue · 0 comments

The Web::Url object is relying a lot on parse_url but this is too flexible and does not always yield a valid URL.
As validation is not done for how urls are passed on the result might be unexpected and throw error unrelated to URL such as invalid Scheme as below

$imageUrl = 'notAUrl';
Url::fromNative($imageUrl);

Throws a type error as parse_url output is not tested

TypeError: Argument 1 passed to ValueObjects\Web\SchemeName::__construct() must be of the type string, null given, called in /var/www/html/vendor/ytake/valueobjects/src/Web/Url.php on line 133

/var/www/html/vendor/ytake/valueobjects/src/Web/SchemeName.php:32
/var/www/html/vendor/ytake/valueobjects/src/Web/Url.php:133