/** * @dataProvider buildRegexpDataProvider * @param integer $expected * @param string $uri * @param string $hostname * @param string $path * @param integer $port * @param string $protocol * @param boolean $anyPort * @param boolean $anySubdomain */ public function testBuildRegexp($expected, $uri, $hostname, $path, $port, $protocol, $anyPort, $anySubdomain) { $host = new Paysera_WalletApi_Entity_Client_Host(); $host->setHost($hostname); $host->setPath($path); $host->setPort($port); $host->setProtocol($protocol); if ($anyPort) { $host->markAsAnyPort(); } if ($anySubdomain) { $host->markAsAnySubdomain(); } $this->assertSame($expected, preg_match($host->buildRegexp(), $uri)); }
/** * Encodes host * * @param Paysera_WalletApi_Entity_Client_Host $host * * @return array * @throws Paysera_WalletApi_Exception_LogicException */ public function encodeHost(Paysera_WalletApi_Entity_Client_Host $host) { if (!$host->getHost()) { throw new Paysera_WalletApi_Exception_LogicException('Host must be provided'); } return array('host' => $host->getHost(), 'port' => $host->getPort(), 'path' => $host->getPath(), 'protocol' => $host->getProtocol(), 'any_port' => $host->isAnyPort(), 'any_subdomain' => $host->isAnySubdomain()); }