assign value to variable, which is then available within template

@param string | array $var
@param mixed $value
@return SimpleTemplate
@throws SimpleTemplateException
559631
public function assign($var, $value = null) {

        $invalidProperties = ['__rawContents'];

		if(is_array($var)) {
			foreach($var as $k => $v) {
			    if(in_array($k, $invalidProperties)) {
			        throw new SimpleTemplateException("Tried to assign invalid property '%s'", $k);
                }
				$this->bufferInstance->$k = $v;
			}

			return $this;
		}

        if(in_array($var, $invalidProperties)) {
            throw new SimpleTemplateException("Tried to assign invalid property '%s'", $var);
        }

		$this->bufferInstance->$var = $value;

		return $this;
	}
402341
public function putVars($key, $value = null)
    {
        if (is_array($key)) {
            $variables = $key;
        } elseif (!is_null($value)) {
            $variables = [$key => $value];
        } else {
            throw new Exception('Try Assets::putVars(["foo" => "bar"]');
        }

        // First, we have to translate the variables
        // to something JS-friendly.
        $this->buildJavaScriptSyntax($variables);

        return $this;
    }
1113892
public function setVariable(string $name, $value = null): self
    {
        $this->variables[$name] = $value;

        return $this;
    }
848971
public function addPlaceholder($name, $value = null, $recursive = false)
    {
        list($name, , $template) = $this->getParentPlaceholder($name);
        if (!isset($template)) {
            $template = $this;
        }
        if ($template === false) {
            if ($this->throwException) {
                throw new TemplateException("Unknown scope: {$name}");
            }
            return;
        }
        $template->placeholders[$name] =
            isset($template->placeholders[$name]) && is_array($template->placeholders[$name])
                ? $this->_merge($template->placeholders[$name], (array)$value, $recursive)
                : $value;
    }
893771
public function set(string $name, $value) : Recipe
    {
        $this->variables->$name = $value;
        return $this;
    }
65422
public function setValue(   $value)
    {
        
     
        // Set the value of the expression and cast it function of the (defined) base type of the variable
        if ($this->attributes['baseType']){
            switch ($this->attributes['baseType']){
                case 'boolean':
                    if (is_string ($value)){
                        $this->value = (bool)($value=='true'||$value=='1'?1:0);
                    }else if (is_bool ($value)){
                        $this->value = $value;
                    }else if ($value == null){
                        $this->value = null;
                    }else{
                        throw new Exception ('taoQTI_models_classes_QTI_response_ExpressionOperator::setValue : an error occured, the value ['.$value.'] is not a well formed boolean');
                    }
                    break;
                case 'float':
                    $this->value = (float)$value;
                    break;
                case 'integer':
                    $this->value = (int)$value;
                    break;
                case 'identifier':
                case 'string':
                    $this->value = (string)$value;
                    break;
                case 'pair':
                    $this->value = taoQTI_models_classes_Matching_VariableFactory::createJSONValueFromQTIData($value, 'pair');
                    break;
                case 'directedPair':
                    $this->value = taoQTI_models_classes_Matching_VariableFactory::createJSONValueFromQTIData($value, 'directedPair');
                    break;
            }   
        }
        
    }
437144
public function add($var, $value)
    {
        if ($this->has($var)) {
            if (is_array($this->container[$var])) {
                $this->container[$var][] = $value;
            } else {
                throw new ModelException(sprintf("Field '%s' exists and is not an array.", $var));
            }
        } else {
            $this->container[$var] = [$value];
        }
        $this->touch();

        return $this;
    }
355038
public function setValue($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Internal\EnumValueDescriptorProto::class);
        $this->value = $arr;
        $this->has_value = true;

        return $this;
    }
277931
public function setCoreDefaultTemplate($value)
    {
        $this->setFieldName('default_template');
        $this->loadObject(true);
        $this->setFieldValue($value);

        return $this;
    }
1324899
public function setAttr($attribute, $value = null)
    {
        if (is_array($attribute) && is_null($value)) {
            foreach ($attribute as $k => $v) {
                $this->setAttr($k, $v);
            }

            return $this;
        }
        $this->template->appendHTML('attributes', ' '.$attribute.'="'.$value.'"');

        return $this;
    }
296919
public function set($var, $value = null)
	{
		if ( ! is_array($var))
		{
			$var = array ($var => $value);
		}

		foreach ($var as $key => $value)
		{
			$value = $this->validateConfig($key, $value);

			if (isset($this->config[$key]))
			{
				// preserve the type
				if (is_bool($this->config[$key]))
				{
					$this->config[$key] = (bool) $value;
				}
				elseif (is_string($this->config[$key]))
				{
					$this->config[$key] = (string) $value;
				}
				else
				{
					$this->config[$key] = (int) $value;
				}
			}
		}
	}
914007
function assign($name,$value=null){
        if(is_array($name)){
            foreach($name as $vk => $v){
                $this->vars[$vk] = $v;
            }
        }else{
            $this->vars[$name] = $value;
        }   
    }
220768
public function set($name, $value)
  {
    if (is_null($value)) {
      unset($this->vars[$name]);
    } else {
      $this->vars[$name] = $value;
    }

    return $this;
  }
594817
public function setInspectTemplate($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InspectTemplate::class);
        $this->inspect_template = $var;

        return $this;
    }
988394
public function setValue($value)
    {
        if (!is_array($value)) {
            $value = [];
        }
        foreach ($value as $key => $value) {
            if (!$this->getElement($key)) {
                continue;
            }
            $this->getElement($key)->setValue($value);
        }

        return $this;
    }
362751
public function setValue(string $value = null) : Element
    {
        $this->value = $value;
        if (isset($this->model)) {
            $this->model->{$this->attributes['name']} = $value;
        }
        return $this;
    }
35196
public function addTemplateVariablesFor($template, array $contentVariables)
    {
        if (!array_key_exists($template, $this->paramArrays)) {
            $this->paramArrays[$template] = $this->getParamArrayFor($template);
        }

        // add vars for main template
        $contentVariables = array_merge($this->paramArrays[$template], $contentVariables);

        // add the template-variables to the contentItem-params-arrays
        if (array_key_exists(self::CONTENT_ITEMS, $contentVariables)) {
            foreach ($contentVariables[self::CONTENT_ITEMS] as $key => $contentItem) {
                // get the key (=> template)
                reset($contentItem);
                $itemTemplate = key($contentItem);

                // get the params
                $itemParams = $contentItem[$itemTemplate];

                // add params for this template
                $contentItem[$itemTemplate] = $this->addTemplateVariablesFor($itemTemplate, $itemParams);

                // store back into the main array
                $contentVariables[self::CONTENT_ITEMS][$key] = $contentItem;
            }
        }

        return $contentVariables;
    }