Chris@14: , Sebastian Heuer , Sebastian Bergmann Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace PharIo\Manifest; Chris@14: Chris@14: class Url { Chris@14: /** Chris@14: * @var string Chris@14: */ Chris@14: private $url; Chris@14: Chris@14: /** Chris@14: * @param string $url Chris@14: * Chris@14: * @throws InvalidUrlException Chris@14: */ Chris@14: public function __construct($url) { Chris@14: $this->ensureUrlIsValid($url); Chris@14: Chris@14: $this->url = $url; Chris@14: } Chris@14: Chris@14: /** Chris@14: * @return string Chris@14: */ Chris@14: public function __toString() { Chris@14: return $this->url; Chris@14: } Chris@14: Chris@14: /** Chris@14: * @param string $url Chris@14: * Chris@14: * @throws InvalidUrlException Chris@14: */ Chris@14: private function ensureUrlIsValid($url) { Chris@14: if (filter_var($url, \FILTER_VALIDATE_URL) === false) { Chris@14: throw new InvalidUrlException; Chris@14: } Chris@14: } Chris@14: }