Adds a parameter that can occur in Fact texts.
@param string $key This is the key which will be searched for in the text.
@param string|Callable $data
@throws \RuntimeException if a parameter with the given $key was already
added.
@return $this
329279
public function addParameter($key, $data)
    {
        if (!is_string($key)) {
            throw new \RuntimeException('Only strings can be given as parameter keys. Got "' . gettype($key) . '".');
        }

        if (!is_string($data) && !is_callable($data)) {
            throw new \RuntimeException('The "data" parameter must either be a string or a callable. . Got "' . gettype($key) . '".');
        }

        if (isset($this->parameters[$key])) {
            throw new \RuntimeException('The parameter key "' . $key . '" is already set.');
        }

        $this->parameters[$key] = $data;

        return $this;
    }
223027
private function validate($key, $data)
    {
        // validates key
        if (in_array($key, $this->unauthorizedKeys)) {
            throw new \RuntimeException(
                'Injected key `'.$key.'` is not authorized. (Unauthorized keys: '.implode(', ', $this->unauthorizedKeys).')'
            );
        }

        if (in_array($key, array_keys($this->injectedData))) {
            throw new \RuntimeException(
                'Injected key `'.$key.'` is already used.'
            );
        }

        // validates data (must be serializable)
        if (false !== $data && false === json_encode($data)) {
            throw new \RuntimeException(
                'Injected data is not serializable.'
            );
        }
    }
247258
public function addOption($key, $value)
    {
        if (!$this->isOptionKeyValid($key)) {
            throw new \RuntimeException('Invalid socket option '.$key.'.');
        }

        $this->options[$key] = $value;

        return $this;
    }
23730
public function setTemplate(array $data, string $key): void
  {
    $this->templateData = $data;
    $this->templateKey  = $key;
  }
208850
protected function setParameter($key, $value)
    {
        if (null !== $this->response) {
            throw new RuntimeException('Request cannot be modified after it has been sent!');
        }
        $this->parameters->set($key, $value);

        return $this;
    }
568315
public static function addData($data, $key = NULL)
    {
        $currentPointer = end(self::$currentPointerStack);
        if (!isset(self::$stackLog[$currentPointer]['messages'])) {
            self::$stackLog[$currentPointer]['messages'] = array();
        }
        if (is_null($key)) {
            self::$stackLog[$currentPointer]['messages'][] = $data;
        } else {
            self::$stackLog[$currentPointer]['messages'][$key] = $data;
        }
    }
913500
protected function setParameter($key, $value)
    {
        if (null !== $this->response) {
            throw new RuntimeException('Request cannot be modified after it has been sent!');
        }

        return $this->setParameterTrait($key, $value);
    }
161833
public static function createFromArray($key, array $data = [])
    {
        $webFormBody = new static($key);

        if (isset($data['formParameters'])) {
            foreach ($data['formParameters'] as $namedParam => $namedParamData) {
                if (\is_array($namedParamData)) {
                    $webFormBody->addParameter(NamedParameter::createFromArray($namedParam, $namedParamData));
                }
            }
        }

        return $webFormBody;
    }
949789
protected static function requireValue($data, $key)
    {
        if (isset($data[$key])) {
            return $data[$key];
        } else {
            throw new Exception\InvalidDataException("Required value for '$key' is missing");
        }
    }
966702
private function parseKey($data, $key)
    {
        if (isset($data[$key])) {
            $value = (int) $data[$key];
            $this->scoreTiers []= new ScoreTier($key, $value);
            return $value;
        }

        throw new InvalidDataException();
    }
172235
public WordNumberCollectorBundle addData(String key, String data) {
        if (JMString.isNumber(data))
            addNumber(key, Double.valueOf(data));
        else
            addWord(key, data);
        return this;
    }
284105
public function addExportData($key, $data = null): PrepareOrderExportEvent
    {
        if (is_array($key)) {
            $this->exportData = array_merge($this->exportData, $key);
        } else {
            $this->exportData[$key] = $data;
        }

        return $this;
    }
288138
public function parse($data, $key = null)
    {
        if ($key) $this->apiKey = $key;
        return $this->get($data, [], null, 'parse');
    }
1313576
public function getParam($key)
    {
        if (array_key_exists($key, $this->params)) {
            return $this->params[$key];
        }

        throw new RuntimeException(sprintf('Parameter with key "%s" is not found.', $key));
    }
930216
public function create(string $key = null)
    {
        if ($key) {
            $this->setStorageKey($key);
        }

        if ($this->exists()) {
            throw new \RuntimeException('Cannot create new object (Already exists)');
        }

        return $this->save();
    }
1324566
public function assign($key, $value)
    {
        if (empty($key)) {
            throw new \RuntimeException('ASSIGN_KEY_EMPTY');
        }
        $this->_data[$key] = $value;

        return $this;
    }
917748
public function setDataByKey($key, $data)
    {
        $data = $this->hydrateIfJsonToArray($data);
        $this->data[$key] = $data;
    }