installed plugin Infinite Uploads
version 2.0.8
This commit is contained in:
37
wp-content/plugins/infinite-uploads/vendor/Aws3/Aws/Endpoint/PatternEndpointProvider.php
vendored
Normal file
37
wp-content/plugins/infinite-uploads/vendor/Aws3/Aws/Endpoint/PatternEndpointProvider.php
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace UglyRobot\Infinite_Uploads\Aws\Endpoint;
|
||||
|
||||
/**
|
||||
* Provides endpoints based on an endpoint pattern configuration array.
|
||||
*/
|
||||
class PatternEndpointProvider
|
||||
{
|
||||
/** @var array */
|
||||
private $patterns;
|
||||
/**
|
||||
* @param array $patterns Hash of endpoint patterns mapping to endpoint
|
||||
* configurations.
|
||||
*/
|
||||
public function __construct(array $patterns)
|
||||
{
|
||||
$this->patterns = $patterns;
|
||||
}
|
||||
public function __invoke(array $args = [])
|
||||
{
|
||||
$service = isset($args['service']) ? $args['service'] : '';
|
||||
$region = isset($args['region']) ? $args['region'] : '';
|
||||
$keys = ["{$region}/{$service}", "{$region}/*", "*/{$service}", "*/*"];
|
||||
foreach ($keys as $key) {
|
||||
if (isset($this->patterns[$key])) {
|
||||
return $this->expand($this->patterns[$key], isset($args['scheme']) ? $args['scheme'] : 'https', $service, $region);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function expand(array $config, $scheme, $service, $region)
|
||||
{
|
||||
$config['endpoint'] = $scheme . '://' . strtr($config['endpoint'], ['{service}' => $service, '{region}' => $region]);
|
||||
return $config;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user