@param $key
@param null $errorMessage
@param null $scalarType

@return IConfig
@throws InvalidConfigValueException
@throws MissingConfigException
9125
public function ensure($key, $errorMessage = null, $scalarType = null) {
        if ( ! $this->has($key)) {
            if ($errorMessage === null) {
                $errorMessage = sprintf('Missing config at key "%s".', $key);
            } else {
                $errorMessage = s('%s: %s', $key, $errorMessage);
            }

            throw new MissingConfigException($errorMessage);
        }

        if ($scalarType !== null) {
            if ( ! str_starts_with(gettype($this->get($key)), $scalarType)) {
                $errorMessage = sprintf('%s: Config value at key "%s" should be of type "%s".', $key, $key, $scalarType);

                throw new InvalidConfigValueException($errorMessage);
            }
        }

        return $this;
    }
15839
public function getStructure(string $key, string $type = null): JsonResponse
    {
        try {
            $form = $this->formManager->getForm($key, $type);
        } catch (HCException $exception) {
            return $this->response->error($exception->getMessage());
        }

        return $this->response->success('OK', $form);
    }
839533
protected function handleError($customMessage = null)
    {
        $message = new stdClass();
        $message->is_error = true;
        if (null !== $customMessage) {
            $message->message = $customMessage;
        }

        return $message;
    }
687132
public static function post($key = null, $type = 'string', $defaultValue = '')
    {
        if (!$key) {
            return $_POST;
        }
        return self::typeConvert(isset($_POST[$key]) ? $_POST[$key] : $defaultValue, $type);
    }
1160304
protected function _normalize($key, $type)
    {
        $type = strtolower($type);

        if ($type !== 'external' && $type !== 'internal')
            throw new \InvalidArgumentException;

        if ($type === 'external')
            $return = $this->_normalizeExternal($key);
        else
            $return = $this->_normalizeInternal($key);

        return $return;
    }
35651
public function setMessage($messageString, $messageKey = null)
    {
        if ($messageKey === null) {
            $keys = array_keys($this->_messageTemplates);
            foreach($keys as $key) {
                $this->setMessage($messageString, $key);
            }
            return $this;
        }

        if (!isset($this->_messageTemplates[$messageKey])) {
            require_once 'Zend/Validate/Exception.php';
            throw new Zend_Validate_Exception("No message template exists for key '$messageKey'");
        }

        $this->_messageTemplates[$messageKey] = $messageString;
        return $this;
    }
87609
void validateSignatureAlgorithmWithKey(JwtConsumerConfig config, Key key) throws InvalidClaimException {
		String signatureAlgorithm = config.getSignatureAlgorithm();
		if (key == null && signatureAlgorithm != null && !signatureAlgorithm.equalsIgnoreCase("none")) {
			String msg = Tr.formatMessage(tc, "JWT_MISSING_KEY", new Object[] { signatureAlgorithm });
			throw new InvalidClaimException(msg);
		}
	}
841497
public function getErrorData($key = null)
    {
        if ($this->isSuccessful()) {
            return null;
        }
        // get error data (array in data)
        $data = isset($this->getData('data')[0]) ? $this->getData('data')[0] : null;
        if ($key) {
            return isset($data[$key]) ? $data[$key] : null;
        }
        return $data;
    }
758462
public function validateType($key, $type, $msg = '') {
        $this->obligate($key);
        $val = $this[$key];
        $msg = $msg ?: sprintf(self::EXCEPTION_INCORRECTTYPE, $key);
        $valid = true;
        if ($type === self::TYPE_ARRAY) {
            $valid = is_array($val);
        } elseif ($type === self::TYPE_OBJECT) {
            $valid = is_object($val);
        } elseif ($type === self::TYPE_NUMBER) {
            $valid = is_int($val) || is_float($val);
        } elseif ($type === self::TYPE_NUMERIC) {
            $valid = is_numeric($val);
        } elseif ($type === self::TYPE_STRING) {
            $valid = is_string($val);
        }

        if (!$valid) {
            throw new Garp_Util_Configuration_Exception_IncorrectType($msg);
        }
        return $this;
    }
599601
protected static function ensureType($type, $value, $errorMessage)
    {
        if (!($value instanceof $type)) {
            throw new PdfTypeException(
                $errorMessage,
                PdfTypeException::INVALID_DATA_TYPE
            );
        }

        return $value;
    }
773870
public function addStatusMessage($textOrArray, $type = 'warning', $icon = 'warning', $insertBefore = 'Root')
    {
        if (!is_null($textOrArray)) {
            
            // Obtain Arguments:
            
            if (is_array($textOrArray)) {
                $text = isset($textOrArray['text']) ? $textOrArray['text'] : null;
                $type = isset($textOrArray['type']) ? $textOrArray['type'] : null;
                $icon = isset($textOrArray['icon']) ? $textOrArray['icon'] : null;
            } else {
                $text = $textOrArray;
            }
            
            // Add Literal Field:
            
            $this->owner->insertBefore(
                $insertBefore,
                LiteralField::create(
                    'StatusMessageLiteral',
                    sprintf(
                        '<p class="message status %s"><i class="fa fa-fw fa-%s"></i> %s</p>',
                        $type,
                        $icon,
                        $text
                    )
                )
            );
            
        }
    }
317560
public function getMessage($type = null, $key = 'messages')
    {
        if (isset($type)) {
            $key .= ".$type";
        }

        $message = $this->get($key, array());
        $this->delete($key);
        return $message;
    }
689248
public function component (GluggiFinder $finder, ComponentConfiguration $componentConfiguration, string $type, string $key)
    {
        try
        {
            $component = $finder->findComponent($type, $key);

            if (null === $component || $component->isHidden())
            {
                $message = null === $component
                    ? "No component found: '%s/%s'"
                    : "The component '%s/%s' has no single view.";

                throw $this->createNotFoundException(sprintf($message, $type, $key));
            }

            $template = $component->getType()->isIsolatedComponentViewMode()
                ? "isolatedComponent"
                : "component";

            return $this->render("@Gluggi/Gluggi/{$template}.html.twig", [
                "component" => $component,
                "type" => $component->getType(),
                "pageTitle" => [
                    $component->getName(),
                    $component->getType()->getName(),
                ],
                "templateConfiguration" => $componentConfiguration->getConfiguration($component),
            ]);
        }
        catch (UnknownComponentTypeException $e)
        {
            throw $this->createNotFoundException($e->getMessage(), $e);
        }
    }
1148391
public function get($key)
    {
        $ret = $this->traverseTree($key);
        if(!is_scalar($ret))
        {
            throw new UnexpectedValueException("The {$key} configuration value is not scalar");
        }
        return $ret;
    }
776379
private static function getConfigValue($key, $config)
    {
        $config = ($config && is_array($config)) ? $config : BlockCypherConfigManager::getInstance()->getConfigHashmap();
        return (array_key_exists($key, $config)) ? trim($config[$key]) : null;
    }
484052
private function assertValidKeyConfiguration(KeyConfiguration $keyConfig)
    {
        if (empty($keyConfig->getHashAlgorithm()) || empty($keyConfig->getSalt()) || empty($keyConfig->getCost())) {
            throw new InvalidKeyConfigurationException();
        }

        $this->assertValidHashAlgorithm($keyConfig);
    }
287619
public function setError($error, $key=null)
	{
		if ($key !== null)
		{
			$this->_errors[$key] = $error;
		}
		else
		{
			array_push($this->_errors, $error);
		}
		return $this;
	}