PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
← All changes | includes/sdk/s3/Aws/functions.php +17 -48 1.2.131.4.1 View file →
@@ -1,11 +1,10 @@
1 1 <?php
2 2
3 3 namespace Dudlewebs\WPMCS\s3\Aws;
4 4
5 -use Dudlewebs\WPMCS\s3\GuzzleHttp\Client;
5 +use Dudlewebs\WPMCS\s3\GuzzleHttp\Utils;
6 6 use Dudlewebs\WPMCS\s3\Psr\Http\Message\RequestInterface;
7 -use Dudlewebs\WPMCS\s3\GuzzleHttp\ClientInterface;
8 7 use Dudlewebs\WPMCS\s3\GuzzleHttp\Promise\FulfilledPromise;
9 8 //-----------------------------------------------------------------------------
10 9 // Functional functions
11 10 //-----------------------------------------------------------------------------
@@ -248,18 +247,9 @@
248 247 * @return callable
249 248 */
250 249 function default_http_handler()
251 250 {
252 - $version = guzzle_major_version();
253 - // If Guzzle 6 or 7 installed
254 - if ($version === 6 || $version === 7) {
255 - return new \Dudlewebs\WPMCS\s3\Aws\Handler\GuzzleV6\GuzzleHandler();
256 - }
257 - // If Guzzle 5 installed
258 - if ($version === 5) {
259 - return new \Dudlewebs\WPMCS\s3\Aws\Handler\GuzzleV5\GuzzleHandler();
260 - }
261 - throw new \RuntimeException('Unknown Guzzle version: ' . $version);
251 + return new \Dudlewebs\WPMCS\s3\Aws\Handler\Guzzle\GuzzleHandler();
262 252 }
263 253 /**
264 254 * Gets the default user agent string depending on the Guzzle version
265 255 *
@@ -266,46 +256,11 @@
266 256 * @return string
267 257 */
268 258 function default_user_agent()
269 259 {
270 - $version = guzzle_major_version();
271 - // If Guzzle 6 or 7 installed
272 - if ($version === 6 || $version === 7) {
273 - return \Dudlewebs\WPMCS\s3\GuzzleHttp\default_user_agent();
274 - }
275 - // If Guzzle 5 installed
276 - if ($version === 5) {
277 - return \Dudlewebs\WPMCS\s3\GuzzleHttp\Client::getDefaultUserAgent();
278 - }
279 - throw new \RuntimeException('Unknown Guzzle version: ' . $version);
260 + return Utils::defaultUserAgent();
280 261 }
281 262 /**
282 - * Get the major version of guzzle that is installed.
283 - *
284 - * @internal This function is internal and should not be used outside aws/aws-sdk-php.
285 - * @return int
286 - * @throws \RuntimeException
287 - */
288 -function guzzle_major_version()
289 -{
290 - static $cache = null;
291 - if (null !== $cache) {
292 - return $cache;
293 - }
294 - if (\defined('Dudlewebs\\WPMCS\\s3\\GuzzleHttp\\ClientInterface::VERSION')) {
295 - $version = (string) ClientInterface::VERSION;
296 - if ($version[0] === '6') {
297 - return $cache = 6;
298 - }
299 - if ($version[0] === '5') {
300 - return $cache = 5;
301 - }
302 - } elseif (\defined('Dudlewebs\\WPMCS\\s3\\GuzzleHttp\\ClientInterface::MAJOR_VERSION')) {
303 - return $cache = ClientInterface::MAJOR_VERSION;
304 - }
305 - throw new \RuntimeException('Unable to determine what Guzzle version is installed.');
306 -}
307 -/**
308 263 * Serialize a request for a command but do not send it.
309 264 *
310 265 * Returns a promise that is fulfilled with the serialized request.
311 266 *
@@ -518,5 +473,19 @@
518 473 */
519 474 function strip_fips_pseudo_regions($region)
520 475 {
521 476 return \str_replace(['fips-', '-fips'], ['', ''], $region);
477 +}
478 +/**
479 + * Checks if an array is associative
480 + *
481 + * @param array $array
482 + *
483 + * @return bool
484 + */
485 +function is_associative(array $array) : bool
486 +{
487 + if (empty($array)) {
488 + return \false;
489 + }
490 + return !\array_is_list($array);
522 491 }