src/ViewModel.php
public function addVariables($variables)
    {
        if ($variables instanceof stdClass) {
            $variables = (array) $variables;
        } elseif ($variables instanceof Traversable) {
            $variables = iterator_to_array($variables);
        } elseif (! is_array($variables)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid variables provided; must be an array or Traversable '
                . 'or instance of stdClass, "%s" received.',
                is_object($variables) ? get_class($variables) : gettype($variables)
            ));
        }
        $this->container = array_merge($this->container, $variables);

        return $this;
    }
public function addVariables($variables)
    {
        if ($variables instanceof stdClass) {
            $variables = (array) $variables;
        } elseif ($variables instanceof Traversable) {
            $variables = iterator_to_array($variables);
        } elseif (! is_array($variables)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid variables provided; must be an array or Traversable '
                . 'or instance of stdClass, "%s" received.',
                is_object($variables) ? get_class($variables) : gettype($variables)
            ));
        }
        $this->container = array_merge($this->container, $variables);

        return $this;
    }
public function addVariables ( $ variables ) { if ( $ variables instanceof stdClass ) { $ variables = ( array ) $ variables ; } elseif ( $ variables instanceof Traversable ) { $ variables = iterator_to_array ( $ variables ) ; } elseif ( ! is_array ( $ variables ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid variables provided; must be an array or Traversable ' . 'or instance of stdClass, "%s" received.' , is_object ( $ variables ) ? get_class ( $ variables ) : gettype ( $ variables ) ) ) ; } $ this -> container = array_merge ( $ this -> container , $ variables ) ; return $ this ; }
Adds the variables.

@param array|\stdClass|\Traversable $variables The variables

@throws \InvalidArgumentException If invalid variables type provided

@return self
Adds the variables .