Assumes that a specific environment variable is set.

@param string $varname
@param string $message

@return void

@throws AssumptionViolatedException
421217
public static function assumeEnvironment($varname, $message = ''): void
    {
        assumeThat(getenv($varname), is(not(false)), $message);
    }
567449
public function includeVariables(array $message_variables)
    {
        // Remove the default template variable key from any variable assignments
        unset($message_variables[self::TEMPLATE_VARIABLE]);

        $this->message_variables = array_merge($this->message_variables, $message_variables);
        $this->assignTemplate();
    }
18686
public static function setVar(string $name, $value)
    {
        // Do not overwrite the variable if it already exists
        if (self::getVar($name) === null) {
            putenv("$name=$value");
            $_ENV[$name] = $value;
            $_SERVER[$name] = $value;
        }
    }
194653
public function setError(?string $message = null) : void
    {
        $this->is_valid = false;
        $this->error = (null === $message) ? $this->default_error : $message;
    }
380934
public static function assumeThat($actual, Matcher $matcher, $message = ''): void
    {
        if (!$matcher->matches($actual)) {
            throw new AssumptionViolatedException($actual, $matcher, $message);
        }
    }
775453
public function error($message): void
	{
		$message = $this->logMessToArray($message);
		$this->log(array_merge(['SEVERITY' => 'ERROR'], $message));
	}
484057
protected function note(...$message): void
    {
        if ($this->notice instanceof Notice) {
            $this->notice->add($message);
        }
    }
809482
function unsetLocalVariable( $varName, $rootNamespace )
    {
        if ( !$this->hasLocalVariable( $varName, $rootNamespace ) )
            return;

        $this->unsetVariable( $varName, $rootNamespace );
        unset( $this->CurrentLocalVariablesNames[$rootNamespace][$varName] );
    }
1332243
public function msgIfExists(string $message = '', array $vars = [])
    {
        $exists = $this->msgExists($message, $vars);
        if ($exists) {
            return $this->msg($message, $vars);
        }
        return $message;
    }
1169302
public static function setEnvironmentVariable($name, $value = null)
    {
        list($name, $value) = static::normaliseEnvironmentVariable($name, $value);

        static::$variables[$name] = $value;
    }
21947
public function failInitialization(string $message, ?\Throwable $error = null): void
    {
        // Log the exception in CloudWatch
        echo "$message\n";
        if ($error) {
            if ($error instanceof \Exception) {
                $errorMessage = get_class($error) . ': ' . $error->getMessage();
            } else {
                $errorMessage = $error->getMessage();
            }
            printf(
                "Fatal error: %s in %s:%d\nStack trace:\n%s",
                $errorMessage,
                $error->getFile(),
                $error->getLine(),
                $error->getTraceAsString()
            );
        }

        $url = "http://{$this->apiUrl}/2018-06-01/runtime/init/error";
        $this->postJson($url, [
            'errorMessage' => $message . ' ' . ($error ? $error->getMessage() : ''),
            'errorType' => $error ? get_class($error) : 'Internal',
            'stackTrace' => $error ? explode(PHP_EOL, $error->getTraceAsString()) : [],
        ]);

        exit(1);
    }
775933
public static function assert($value, $varName) {
        return !is_string($value) && $value !== null ? Exceptions::InvalidTypeException('MaybeString', $varName, $value) : $value;
    }
679632
static public function notEq($value1, $value2, $message = null, $propertyPath = null)
        {
            if ($value1 == $value2) {
                $message = $message ?: sprintf(
                    'Value "%s" is equal to expected value "%s".',
                    static::stringify($value1),
                    static::stringify($value2)
                );

                throw static::createException($value1, $message,static::INVALID_NOT_EQ, $propertyPath, array('expected' => $value2));
            }
        }
881120
public static function assert($value, $varName) {
        if(!is_array($value)) return Exceptions::InvalidTypeException('HashMapEntry', $varName, $value);
        if(count($value) > 1) return Exceptions::InvalidTypeException('HashMapEntry', $varName, $value);

        $keys = array_keys($value);
        $key  = end($keys);

        Str::assert($key, 'HashMapEntry of "' . $varName . '": "' . $key . '"');

        return $value;
    }
84044
public function setMessage($message = '')
    {
        if (!is_string($message)) {
            throw new BuildException(
                '"message" attribute is invalid.' .
                ' Expect to be a string, actual is ' . gettype($message)
            );
        }

        $this->message = $message;
    }
677569
protected function createMessage($message, $variables = null)
    {
        if (null !== $variables && is_array($variables)) {
            $variables = array_merge($this->getMessageVariables(), $variables);
        } else {
            $variables = $this->getMessageVariables();
        }

        foreach ($variables as $variableKey => $variable) {
            if (is_array($variable) || ($variable instanceof Traversable)) {
                $variable = implode(', ', array_values($variable));
            }

            if (!is_scalar($variable)) {
                $variable = $this->switchType($variable);
            }

            $message = str_replace("%$variableKey%", (string) $variable, $message);
        }

        return $message;
    }
1035852
public function error($message)
    {
        if ($this->logger) {
            $this->logger->error($message);
        }
        if (!$this->debug) {
            throw new \RuntimeException($message);
        }
    }