[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 declare(strict_types=1); 4 5 /* 6 * The MIT License (MIT) 7 * 8 * Copyright (c) 2014-2019 Spomky-Labs 9 * 10 * This software may be modified and distributed under the terms 11 * of the MIT license. See the LICENSE file for details. 12 */ 13 14 namespace Webauthn\MetadataService; 15 16 use function League\Uri\build; 17 use function League\Uri\build_query; 18 use function League\Uri\parse; 19 use function League\Uri\parse_query; 20 use Psr\Http\Client\ClientInterface; 21 use Psr\Http\Message\RequestFactoryInterface; 22 23 class MetadataService 24 { 25 /** 26 * @var ClientInterface 27 */ 28 private $httpClient; 29 30 /** 31 * @var RequestFactoryInterface 32 */ 33 private $requestFactory; 34 35 /** 36 * @var array 37 */ 38 private $additionalQueryStringValues; 39 40 /** 41 * @var array 42 */ 43 private $additionalHeaders; 44 /** 45 * @var string 46 */ 47 private $serviceUri; 48 49 public function __construct(string $serviceUri, ClientInterface $httpClient, RequestFactoryInterface $requestFactory, array $additionalQueryStringValues = [], array $additionalHeaders = []) 50 { 51 $this->serviceUri = $serviceUri; 52 $this->httpClient = $httpClient; 53 $this->requestFactory = $requestFactory; 54 $this->additionalQueryStringValues = $additionalQueryStringValues; 55 $this->additionalHeaders = $additionalHeaders; 56 } 57 58 public function getMetadataStatementFor(MetadataTOCPayloadEntry $entry): MetadataStatement 59 { 60 $uri = $this->buildUri($entry->getUrl()); 61 62 return MetadataStatementFetcher::fetchMetadataStatement($uri, true, $this->httpClient, $this->requestFactory, $this->additionalHeaders); 63 } 64 65 public function getMetadataTOCPayload(): MetadataTOCPayload 66 { 67 $uri = $this->buildUri($this->serviceUri); 68 69 return MetadataStatementFetcher::fetchTableOfContent($uri, $this->httpClient, $this->requestFactory, $this->additionalHeaders); 70 } 71 72 private function buildUri(string $uri): string 73 { 74 $parsedUri = parse($uri); 75 $queryString = $parsedUri['query']; 76 $query = parse_query($queryString ?? ''); 77 foreach ($this->additionalQueryStringValues as $k => $v) { 78 $query[$k] = $v; 79 } 80 $parsedUri['query'] = build_query($query); 81 82 return build($parsedUri); 83 } 84 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |