src/Styling.php
protected function wrapScalar($var, $name)
    {
        self::checkVariableName($name);

        if (is_object($var)) {
            if ($var instanceof \Erebot\Styling\VariableInterface) {
                return $var;
            }

            if (!is_callable(array($var, '__toString'), false)) {
                throw new \InvalidArgumentException(
                    $name.' must be a scalar or an instance of '.
                    '\\Erebot\\Styling\\VariableInterface'
                );
            }
        }

        if (is_array($var)) {
            return $var;
        }

        if (is_string($var) || is_callable(array($var, '__toString'), false)) {
            $cls = $this->cls['string'];
        } elseif (is_int($var)) {
            $cls = $this->cls['int'];
        } elseif (is_float($var)) {
            $cls = $this->cls['float'];
        } else {
            throw new \InvalidArgumentException(
                'Unsupported scalar type ('.gettype($var).') for "'.$name.'"'
            );
        }
        return new $cls($var);
    }
protected function wrapScalar($var, $name)
    {
        self::checkVariableName($name);

        if (is_object($var)) {
            if ($var instanceof \Erebot\Styling\VariableInterface) {
                return $var;
            }

            if (!is_callable(array($var, '__toString'), false)) {
                throw new \InvalidArgumentException(
                    $name.' must be a scalar or an instance of '.
                    '\\Erebot\\Styling\\VariableInterface'
                );
            }
        }

        if (is_array($var)) {
            return $var;
        }

        if (is_string($var) || is_callable(array($var, '__toString'), false)) {
            $cls = $this->cls['string'];
        } elseif (is_int($var)) {
            $cls = $this->cls['int'];
        } elseif (is_float($var)) {
            $cls = $this->cls['float'];
        } else {
            throw new \InvalidArgumentException(
                'Unsupported scalar type ('.gettype($var).') for "'.$name.'"'
            );
        }
        return new $cls($var);
    }
protected function wrapScalar ( $ var , $ name ) { self :: checkVariableName ( $ name ) ; if ( is_object ( $ var ) ) { if ( $ var instanceof \ Erebot \ Styling \ VariableInterface ) { return $ var ; } if ( ! is_callable ( array ( $ var , '__toString' ) , false ) ) { throw new \ InvalidArgumentException ( $ name . ' must be a scalar or an instance of ' . '\\Erebot\\Styling\\VariableInterface' ) ; } } if ( is_array ( $ var ) ) { return $ var ; } if ( is_string ( $ var ) || is_callable ( array ( $ var , '__toString' ) , false ) ) { $ cls = $ this -> cls [ 'string' ] ; } elseif ( is_int ( $ var ) ) { $ cls = $ this -> cls [ 'int' ] ; } elseif ( is_float ( $ var ) ) { $ cls = $ this -> cls [ 'float' ] ; } else { throw new \ InvalidArgumentException ( 'Unsupported scalar type (' . gettype ( $ var ) . ') for "' . $ name . '"' ) ; } return new $ cls ( $ var ) ; }
Wraps a scalar into the appropriate
styling object.

\param mixed $var
Either a scalar, an array or an object implementing
the ::Erebot::Styling::VariableInterface interface.
Scalar values will be wrapped with the appropriate
object while arrays and objects are returned untouched.

\param string $name
Name of given variable.

\retval array
If \a $var referred to an array, it is returned
without any modification.

\retval ::Erebot::Styling::VariableInterface_Variable
Objects that implement ::Erebot::Styling::VariableInterface
are returned without any modification. Scalar values
are wrapped into the appropriate object implementing
the ::Erebot::Styling::VariableInterface interface and
the resulting object is returned.

\throw ::InvalidArgumentException
Either the given name is invalid, or the given value
was not a scalar.

\note
In the context of this method, objects that can be
converted to a string (ie. implement __toString())
are treated as if they were a string (and thus, are
considered as scalar values).
Wraps a scalar into the appropriate styling object .