/** * Get the current UrlBuilder object. * @return UrlBuilder The current UrlBuilder. */ public static function getInstance() { if (self::$instance == NULL) { self::$instance = new self(); } return self::$instance; }
public function testAll() { $builder = UrlBuilder::url("example.com"); $builder->protocol("https"); $builder->path("some/path"); $builder->parameter("var1", "value1"); $builder->parameter("var2", "value2"); $this->assertSame("https://example.com/some/path?var1=value1&var2=value2", $builder->build()); }
public function testGetInvalidUrl() { $this->setExpectedException('\\InvalidArgumentException', 'Not a valid path.'); $urlBuilder = new UrlBuilder(':80'); $urlBuilder->getUrl('image.jpg'); }
public function testBuildPeriodsUrlReturnValidUrl() { $urlBuilder = new UrlBuilder('token1'); $this->assertEquals('https://www.fio.cz/ib_api/rest/periods/token1/2015-03-25/2015-03-31/transactions.json', $urlBuilder->buildPeriodsUrl(new \DateTime('2015-03-25'), new \DateTime('2015-03-31'))); }
/** * Creates a new UrlBuilder using $components * * @param array $components * * @return UrlBuilder */ public static function createFromComponents(array $components) { $urlbuilder = new UrlBuilder(); $urlbuilder->setComponents($components); return $urlbuilder; }
/** * Returns the parameters for the url. Overwrites its parent in the * {@link UrlBuilder}. * * @return String[] the parameters for the url. * @public * @version 0.0.1 * @since 0.0.1 */ function getParameters() { $params = array(); for ($i = 0; $i < count($this->showParameters); $i++) { $params["show[{$i}]"] = $this->showParameters[$i]; } return array_merge(parent::getParameters(), $params); }