public function testFullUsage() { $u = new \Ark4ne\Helpers\URL('www.github.com/Ark4ne/php-helpers'); $this->assertEquals('http://www.github.com/Ark4ne/php-helpers', (string) $u); $u->setSecure(true); $this->assertEquals('https://www.github.com/Ark4ne/php-helpers', (string) $u); $u->setProtocol('git'); $u->setSecure(false); $this->assertEquals('git://www.github.com/Ark4ne/php-helpers', (string) $u); $u->setProtocol('ftp'); $u->setSecure(true); $this->assertEquals('ftps://www.github.com/Ark4ne/php-helpers', (string) $u); }
/** * Return formatted url. * * @param string $to * @param array $params * @param null|bool $secure * @param null|bool $domain * * @return string */ function ark_url($to, $params = [], $secure = null, $domain = null) { $url = new \Ark4ne\Helpers\URL($to); foreach ($params as $key => $value) { $url->addParam($key, $value); } $secure !== null && $url->setSecure($secure); $domain !== null && $url->setDomainString($domain); return (string) $url; }