本文整理汇总了PHP中Url::fromString方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::fromString方法的具体用法?PHP Url::fromString怎么用?PHP Url::fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url::fromString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHostAndPort
public function testHostAndPort()
{
$urlStr = 'foo:8080';
$url = Url::fromString($urlStr);
$this->assertEquals('foo', $url->getHost());
$this->assertEquals('8080', $url->getPort());
}
示例2: resolve
/**
* @param RequestInterface $request
* @param MapInterface<string, AttributeInterface> $attributes
* @param UrlInterface $target
*/
public function resolve(RequestInterface $request, MapInterface $attributes, UrlInterface $target) : UrlInterface
{
$base = $request->url();
if ($attributes->contains(BaseParser::key())) {
$base = $attributes->get(BaseParser::key())->content();
}
return Url::fromString($this->resolver->resolve((string) $base, (string) $target));
}
示例3: server
public function server(string $url) : ServerInterface
{
$url = Url::fromString($url);
$hash = md5((string) $url);
if ($this->servers->contains($hash)) {
return $this->servers->get($hash);
}
$server = $this->makeServer($url);
$this->servers = $this->servers->put($hash, $server);
return $server;
}
示例4: get
public function get(string $name) : HttpResource
{
if (!$this->names()->contains($name)) {
throw new InvalidArgumentException();
}
if ($this->definitions->contains($name)) {
return $this->definitions->get($name);
}
$url = $this->resolver->resolve((string) $this->host, (string) $this->paths->get($name));
$url = Url::fromString($url);
$response = $this->transport->fulfill(new Request($url, new Method(Method::OPTIONS), new ProtocolVersion(1, 1), new Headers(new Map('string', HeaderInterface::class)), new NullStream()));
$definition = $this->factory->make($name, $url, $response);
$this->definitions = $this->definitions->put($name, $definition);
return $definition;
}
示例5: getTagList
/**
* Returns protected var $oberserver.
* @param string observer key
* @return array
*/
public function getTagList($param)
{
$id = $param['id'];
$tree_id = $param['tree_id'];
$url_edit = new Url();
$url_del = new Url();
$url_edit->fromString($param['href_edit_theme_tag']);
$url_del->fromString($param['href_del_theme_tag']);
try {
$siteTag = new SystemSiteTag();
$theme = $this->director->themeManager->getThemeFromId(array('id' => $id));
$usedTags = $siteTag->getTagList(array('tree_id' => $tree_id));
$taglist = $theme->getTagList();
foreach ($taglist as &$item) {
$item['userdefined'] = array_key_exists($item['id'], $usedTags) ? join(', ', $usedTags[$item['id']]) : '';
$url_edit->setParameter('parent_tag', $item['id']);
$url_del->setParameter('parent_tag', $item['id']);
$item['href_edit'] = $url_edit->getUrl();
$item['href_del'] = $item['userdefined'] ? $url_del->getUrl() : '';
}
return array_values($taglist);
} catch (Exception $e) {
return $e->getMessage();
}
}
示例6: resolveUrl
private function resolveUrl(UrlInterface $url, IdentityInterface $identity) : UrlInterface
{
$url = (string) $url;
$url = rtrim($url, '/') . '/' . $identity;
return Url::fromString($url);
}
示例7: webhookUrl
/**
* @param string $webhookUrl
* @return Url|null
*/
public function webhookUrl($webhookUrl = null)
{
if ($webhookUrl !== null) {
$this->webhookUrl = Url::fromString($webhookUrl);
}
return $this->webhookUrl;
}
示例8: fromArray
/**
* @param array $order
* @return Order
*/
public static function fromArray(array $order)
{
Guard::keyExists($order, 'transactions');
Guard::keyExists($order, 'amount');
Guard::keyExists($order, 'currency');
return new static(Transactions::fromArray($order['transactions']), Amount::fromInteger($order['amount']), Currency::fromString($order['currency']), array_key_exists('description', $order) ? Description::fromString($order['description']) : null, array_key_exists('merchant_order_id', $order) ? MerchantOrderId::fromString($order['merchant_order_id']) : null, array_key_exists('return_url', $order) ? Url::fromString($order['return_url']) : null, array_key_exists('expiration_period', $order) ? new \DateInterval($order['expiration_period']) : null, array_key_exists('id', $order) ? Uuid::fromString($order['id']) : null, array_key_exists('project_id', $order) ? Uuid::fromString($order['project_id']) : null, array_key_exists('created', $order) ? new Carbon($order['created']) : null, array_key_exists('modified', $order) ? new Carbon($order['modified']) : null, array_key_exists('completed', $order) ? new Carbon($order['completed']) : null, array_key_exists('status', $order) ? Status::fromString($order['status']) : null);
}
示例9: parseValues
protected function parseValues(SetInterface $values)
{
return $values->reduce(new Set(UrlInterface::class), function (Set $urls, string $url) : Set {
return $urls->add(Url::fromString($url));
});
}