# media-cloud-sync/1.4.2/includes/sdk/google/ramsey/collection/src/Map/NamedParameterMap.php

Media Cloud Sync, version 1.4.2. 91 lines.

- Page: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/code/includes/sdk/google/ramsey/collection/src/Map/NamedParameterMap.php
- Raw: https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/raw/includes/sdk/google/ramsey/collection/src/Map/NamedParameterMap.php
- Modified: 2026-05-26T18:20:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/media-cloud-sync/1.4.2/code/includes/sdk/google/ramsey/collection/src/Map/NamedParameterMap.php#L10-L20`.

```php
<?php

/**
 * This file is part of the ramsey/collection library
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
 * @license http://opensource.org/licenses/MIT MIT
 */
declare (strict_types=1);
namespace Dudlewebs\WPMCS\GCP\Ramsey\Collection\Map;

use Dudlewebs\WPMCS\GCP\Ramsey\Collection\Exception\InvalidArgumentException;
use Dudlewebs\WPMCS\GCP\Ramsey\Collection\Tool\TypeTrait;
use Dudlewebs\WPMCS\GCP\Ramsey\Collection\Tool\ValueToStringTrait;
use function array_combine;
use function array_key_exists;
use function is_int;
/**
 * `NamedParameterMap` represents a mapping of values to a set of named keys
 * that may optionally be typed
 *
 * @extends AbstractMap<string, mixed>
 */
class NamedParameterMap extends AbstractMap
{
    use TypeTrait;
    use ValueToStringTrait;
    /**
     * Named parameters defined for this map.
     *
     * @var array<string, string>
     */
    private readonly array $namedParameters;
    /**
     * Constructs a new `NamedParameterMap`.
     *
     * @param array<array-key, string> $namedParameters The named parameters defined for this map.
     * @param array<string, mixed> $data An initial set of data to set on this map.
     */
    public function __construct(array $namedParameters, array $data = [])
    {
        $this->namedParameters = $this->filterNamedParameters($namedParameters);
        parent::__construct($data);
    }
    /**
     * Returns named parameters set for this `NamedParameterMap`.
     *
     * @return array<string, string>
     */
    public function getNamedParameters() : array
    {
        return $this->namedParameters;
    }
    public function offsetSet(mixed $offset, mixed $value) : void
    {
        if (!array_key_exists($offset, $this->namedParameters)) {
            throw new InvalidArgumentException('Attempting to set value for unconfigured parameter \'' . $this->toolValueToString($offset) . '\'');
        }
        if ($this->checkType($this->namedParameters[$offset], $value) === \false) {
            throw new InvalidArgumentException('Value for \'' . $offset . '\' must be of type ' . $this->namedParameters[$offset] . '; value is ' . $this->toolValueToString($value));
        }
        $this->data[$offset] = $value;
    }
    /**
     * Given an array of named parameters, constructs a proper mapping of
     * named parameters to types.
     *
     * @param array<array-key, string> $namedParameters The named parameters to filter.
     *
     * @return array<string, string>
     */
    protected function filterNamedParameters(array $namedParameters) : array
    {
        $names = [];
        $types = [];
        foreach ($namedParameters as $key => $value) {
            if (is_int($key)) {
                $names[] = $value;
                $types[] = 'mixed';
            } else {
                $names[] = $key;
                $types[] = $value;
            }
        }
        return array_combine($names, $types) ?: [];
    }
}

```
