コード例 #1
0
 public function test_setters()
 {
     $expected = 'https://*****:*****@xn--pia-8ma.com:80/one/two/three?key=val#fragment';
     $urlComposer = new UrlComposer('');
     $urlComposer->setScheme('https')->setHost('piña.com')->setUser('retrinko')->setPass('123456')->setPort(80)->setPath(['one', 'two', 'three'])->setQuery(['key' => 'val'])->setFragment('fragment');
     $url = $urlComposer->compose();
     $this->assertEquals($expected, $url);
 }
コード例 #2
0
ファイル: basic.php プロジェクト: retrinko/url-composer
<?php

require_once __DIR__ . '/../vendor/autoload.php';
use Retrinko\UrlComposer\UrlComposer;
try {
    $urlComposer = new UrlComposer('http://my-url.com');
    $urlComposer->setUser('user')->addToPath('blog')->addToQuery('id', '25')->setFragment('fragment');
    $url = $urlComposer->compose();
    printf('URL: %s' . PHP_EOL, $url);
} catch (\Exception $e) {
    printf('Exception!: %s' . PHP_EOL, $e->getMessage());
}