ValueObjects\Web\Url::sameValueAs PHP Метод

sameValueAs() публичный Метод

Tells whether two Url are sameValueAs by comparing their components
public sameValueAs ( ValueObjects\ValueObjectInterface $url ) : boolean
$url ValueObjects\ValueObjectInterface
Результат boolean
    public function sameValueAs(ValueObjectInterface $url)
    {
        if (false === Util::classEquals($this, $url)) {
            return false;
        }
        return $this->getScheme()->sameValueAs($url->getScheme()) && $this->getUser()->sameValueAs($url->getUser()) && $this->getPassword()->sameValueAs($url->getPassword()) && $this->getDomain()->sameValueAs($url->getDomain()) && $this->getPath()->sameValueAs($url->getPath()) && $this->getPort()->sameValueAs($url->getPort()) && $this->getQueryString()->sameValueAs($url->getQueryString()) && $this->getFragmentIdentifier()->sameValueAs($url->getFragmentIdentifier());
    }

Usage Example

Пример #1
0
 public function testSameValueAs()
 {
     $url2 = new Url(new SchemeName('http'), new StringLiteral('user'), new StringLiteral('pass'), new Hostname('foo.com'), new PortNumber(80), new Path('/bar'), new QueryString('?querystring'), new FragmentIdentifier('#fragmentidentifier'));
     $url3 = new Url(new SchemeName('git+ssh'), new StringLiteral(''), new StringLiteral(''), new Hostname('github.com'), new NullPortNumber(), new Path('/nicolopignatelli/valueobjects'), new QueryString('?querystring'), new FragmentIdentifier('#fragmentidentifier'));
     $this->assertTrue($this->url->sameValueAs($url2));
     $this->assertTrue($url2->sameValueAs($this->url));
     $this->assertFalse($this->url->sameValueAs($url3));
     $mock = $this->getMock('ValueObjects\\ValueObjectInterface');
     $this->assertFalse($this->url->sameValueAs($mock));
 }