Phly\Http\Uri::withHost PHP Method

withHost() public method

public withHost ( $host )
    public function withHost($host)
    {
        if ($host === $this->host) {
            // Do nothing if no change was made.
            return clone $this;
        }
        $new = clone $this;
        $new->host = $host;
        return $new;
    }

Usage Example

Ejemplo n.º 1
0
 public function testWithHostReturnsNewInstanceWithProvidedHost()
 {
     $uri = new Uri('https://*****:*****@local.example.com:3001/foo?bar=baz#quz');
     $new = $uri->withHost('framework.zend.com');
     $this->assertNotSame($uri, $new);
     $this->assertEquals('framework.zend.com', $new->getHost());
     $this->assertEquals('https://*****:*****@framework.zend.com:3001/foo?bar=baz#quz', (string) $new);
 }
All Usage Examples Of Phly\Http\Uri::withHost