PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.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 All 36 releases
← All changes | includes/sdk/google/ramsey/collection/src/Map/NamedParameterMap.php +11 -18 1.2.2 → 1.4.2 View file →
@@ -9,22 +9,21 @@
9 9 * @copyright Copyright (c) Ben Ramsey <[email protected]>
10 10 * @license http://opensource.org/licenses/MIT MIT
11 11 */
12 12 declare (strict_types=1);
13 -namespace Dudlewebs\WPMCS\Ramsey\Collection\Map;
13 +namespace Dudlewebs\WPMCS\GCP\Ramsey\Collection\Map;
14 14
15 -use Dudlewebs\WPMCS\Ramsey\Collection\Exception\InvalidArgumentException;
16 -use Dudlewebs\WPMCS\Ramsey\Collection\Tool\TypeTrait;
17 -use Dudlewebs\WPMCS\Ramsey\Collection\Tool\ValueToStringTrait;
15 +use Dudlewebs\WPMCS\GCP\Ramsey\Collection\Exception\InvalidArgumentException;
16 +use Dudlewebs\WPMCS\GCP\Ramsey\Collection\Tool\TypeTrait;
17 +use Dudlewebs\WPMCS\GCP\Ramsey\Collection\Tool\ValueToStringTrait;
18 18 use function array_combine;
19 19 use function array_key_exists;
20 20 use function is_int;
21 -use function var_export;
22 21 /**
23 22 * `NamedParameterMap` represents a mapping of values to a set of named keys
24 23 * that may optionally be typed
25 24 *
26 - * @extends AbstractMap<mixed>
25 + * @extends AbstractMap<string, mixed>
27 26 */
28 27 class NamedParameterMap extends AbstractMap
29 28 {
30 29 use TypeTrait;
@@ -33,14 +32,14 @@
33 32 * Named parameters defined for this map.
34 33 *
35 34 * @var array<string, string>
36 35 */
37 - protected array $namedParameters;
36 + private readonly array $namedParameters;
38 37 /**
39 38 * Constructs a new `NamedParameterMap`.
40 39 *
41 40 * @param array<array-key, string> $namedParameters The named parameters defined for this map.
42 - * @param array<array-key, mixed> $data An initial set of data to set on this map.
41 + * @param array<string, mixed> $data An initial set of data to set on this map.
43 42 */
44 43 public function __construct(array $namedParameters, array $data = [])
45 44 {
46 45 $this->namedParameters = $this->filterNamedParameters($namedParameters);
@@ -50,22 +49,16 @@
50 49 * Returns named parameters set for this `NamedParameterMap`.
51 50 *
52 51 * @return array<string, string>
53 52 */
54 - public function getNamedParameters(): array
53 + public function getNamedParameters() : array
55 54 {
56 55 return $this->namedParameters;
57 56 }
58 - /**
59 - * @inheritDoc
60 - */
61 - public function offsetSet($offset, $value): void
57 + public function offsetSet(mixed $offset, mixed $value) : void
62 58 {
63 - if ($offset === null) {
64 - throw new InvalidArgumentException('Map elements are key/value pairs; a key must be provided for ' . 'value ' . var_export($value, \true));
65 - }
66 59 if (!array_key_exists($offset, $this->namedParameters)) {
67 - throw new InvalidArgumentException('Attempting to set value for unconfigured parameter \'' . $offset . '\'');
60 + throw new InvalidArgumentException('Attempting to set value for unconfigured parameter \'' . $this->toolValueToString($offset) . '\'');
68 61 }
69 62 if ($this->checkType($this->namedParameters[$offset], $value) === \false) {
70 63 throw new InvalidArgumentException('Value for \'' . $offset . '\' must be of type ' . $this->namedParameters[$offset] . '; value is ' . $this->toolValueToString($value));
71 64 }
@@ -78,9 +71,9 @@
78 71 * @param array<array-key, string> $namedParameters The named parameters to filter.
79 72 *
80 73 * @return array<string, string>
81 74 */
82 - protected function filterNamedParameters(array $namedParameters): array
75 + protected function filterNamedParameters(array $namedParameters) : array
83 76 {
84 77 $names = [];
85 78 $types = [];
86 79 foreach ($namedParameters as $key => $value) {