PluginProbe
Media Cloud Sync / 1.2.2
Media Cloud Sync v1.2.2
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
media-cloud-sync / includes / sdk / s3 / Aws / Retry / Configuration.php

Configuration.php in Media Cloud Sync 1.2.2, at includes/sdk/s3/Aws/Retry/Configuration.php

45 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\Retry;
4
5 use Dudlewebs\WPMCS\s3\Aws\Retry\Exception\ConfigurationException;
6 class Configuration implements ConfigurationInterface
7 {
8 private $mode;
9 private $maxAttempts;
10 private $validModes = ['legacy', 'standard', 'adaptive'];
11 public function __construct($mode = 'legacy', $maxAttempts = 3)
12 {
13 $mode = \strtolower($mode);
14 if (!\in_array($mode, $this->validModes)) {
15 throw new ConfigurationException("'{$mode}' is not a valid mode." . " The mode has to be 'legacy', 'standard', or 'adaptive'.");
16 }
17 if (!\is_numeric($maxAttempts) || \intval($maxAttempts) != $maxAttempts || $maxAttempts < 1) {
18 throw new ConfigurationException("The 'maxAttempts' parameter has" . " to be an integer >= 1.");
19 }
20 $this->mode = $mode;
21 $this->maxAttempts = \intval($maxAttempts);
22 }
23 /**
24 * {@inheritdoc}
25 */
26 public function getMode()
27 {
28 return $this->mode;
29 }
30 /**
31 * {@inheritdoc}
32 */
33 public function getMaxAttempts()
34 {
35 return $this->maxAttempts;
36 }
37 /**
38 * {@inheritdoc}
39 */
40 public function toArray()
41 {
42 return ['mode' => $this->getMode(), 'max_attempts' => $this->getMaxAttempts()];
43 }
44 }
45