Beispiel #1
0
 /**
  * @param string $url Url to be tested
  * @param boolean $valid True if the given URL is considered has a valid one
  * @dataProvider provideUrls
  */
 public function testUrl($url, $valid = true)
 {
     $this->assertEquals($valid, Url::isValid($url));
     if ($valid == false) {
         $this->setExpectedException('\\InvalidArgumentException');
     }
     $object = new Url($url);
     $this->assertEquals($url, (string) $object);
 }
Beispiel #2
0
 /**
  * @param string $url
  */
 public function __construct($url)
 {
     if (!is_string($url)) {
         throw new InvalidArgumentException('url given must be a valid string!');
     }
     if (!Url::isValid($url)) {
         throw new InvalidArgumentException('url given is not a valid url (according to PHP FILTER_VALIDATE_URL). ' . $url);
     }
     //Define default entries
     if (($parsed = parse_url($url)) !== false) {
         foreach ($parsed as $name => $value) {
             $this->{$name}($value);
         }
     }
 }