Beispiel #1
0
 public function testInitFull()
 {
     $parser = new Parser("foo://*****:*****@baz.zab:123/quux?foo=bar#baz");
     $this->assertEquals('foo', $parser->getScheme());
     $this->assertEquals('bar', $parser->getUser());
     $this->assertEquals('rab', $parser->getPass());
     $this->assertEquals('baz.zab', $parser->getHost());
     $this->assertEquals(123, $parser->getPort());
     $this->assertEquals('/quux', $parser->getPath());
     $this->assertEquals('foo=bar', $parser->getQuery());
     $this->assertEquals('baz', $parser->getFragment());
 }
Beispiel #2
0
 public function __construct($str)
 {
     if (strstr($str, $this->getProtocol() . '://') !== 0) {
         $str = $this->getProtocol() . '://' . $str;
     }
     parent::__construct($str);
     if (!isset($this->pieces["host"]) || empty($this->pieces['host'])) {
         throw new \InvalidArgumentException("Host can't be empty");
     }
     if (!isset($this->pieces["path"]) || empty($this->pieces['path'])) {
         throw new \InvalidArgumentException("Database can't be empty");
     }
 }