public function writeScalar($scalar)
    {
        if (Utils::isScalar($scalar) === false) {
            $msg = "A '" . gettype($scalar) . "' value is not a PHP scalar value nor null.";
            throw new InvalidArgumentException($msg);
        }

        try {
            if (is_int($scalar) === true) {
                $this->getStream()->write($scalar);
            } elseif (is_double($scalar) === true) {
                if (strpos('' . $scalar, '.') === false) {
                    $scalar = $scalar . '.0';
                }

                $this->getStream()->write($scalar);
            } elseif (is_string($scalar) === true) {
                $this->getStream()->write(PhpUtils::doubleQuotedPhpString($scalar));
            } elseif (is_bool($scalar) === true) {
                $this->getStream()->write(($scalar === true) ? 'true' : 'false');
            } elseif (is_null($scalar) === true) {
                $this->getStream()->write('null');
            }
        } catch (StreamException $e) {
            $msg = "An error occured while writing the scalar value '${scalar}'.";
            throw new StreamAccessException($msg, $this, 0, $e);
        }
    }
public function writeScalar($scalar)
    {
        if (Utils::isScalar($scalar) === false) {
            $msg = "A '" . gettype($scalar) . "' value is not a PHP scalar value nor null.";
            throw new InvalidArgumentException($msg);
        }

        try {
            if (is_int($scalar) === true) {
                $this->getStream()->write($scalar);
            } elseif (is_double($scalar) === true) {
                if (strpos('' . $scalar, '.') === false) {
                    $scalar = $scalar . '.0';
                }

                $this->getStream()->write($scalar);
            } elseif (is_string($scalar) === true) {
                $this->getStream()->write(PhpUtils::doubleQuotedPhpString($scalar));
            } elseif (is_bool($scalar) === true) {
                $this->getStream()->write(($scalar === true) ? 'true' : 'false');
            } elseif (is_null($scalar) === true) {
                $this->getStream()->write('null');
            }
        } catch (StreamException $e) {
            $msg = "An error occured while writing the scalar value '${scalar}'.";
            throw new StreamAccessException($msg, $this, 0, $e);
        }
    }
public function writeScalar ( $ scalar ) { if ( Utils :: isScalar ( $ scalar ) === false ) { $ msg = "A '" . gettype ( $ scalar ) . "' value is not a PHP scalar value nor null." ; throw new InvalidArgumentException ( $ msg ) ; } try { if ( is_int ( $ scalar ) === true ) { $ this -> getStream ( ) -> write ( $ scalar ) ; } elseif ( is_double ( $ scalar ) === true ) { if ( strpos ( '' . $ scalar , '.' ) === false ) { $ scalar = $ scalar . '.0' ; } $ this -> getStream ( ) -> write ( $ scalar ) ; } elseif ( is_string ( $ scalar ) === true ) { $ this -> getStream ( ) -> write ( PhpUtils :: doubleQuotedPhpString ( $ scalar ) ) ; } elseif ( is_bool ( $ scalar ) === true ) { $ this -> getStream ( ) -> write ( ( $ scalar === true ) ? 'true' : 'false' ) ; } elseif ( is_null ( $ scalar ) === true ) { $ this -> getStream ( ) -> write ( 'null' ) ; } } catch ( StreamException $ e ) { $ msg = "An error occured while writing the scalar value '${scalar}'." ; throw new StreamAccessException ( $ msg , $ this , 0 , $ e ) ; } }
Write a scalar value into the current stream.

If the given value is a string, it will be output surrounded by double quotes (") characters.

@param mixed $scalar A PHP scalar value or null.
@throws InvalidArgumentException If $scalar is not a PHP scalar value nor null.
@throws StreamAccessException If an error occurs while writing the scalar value.
Write a scalar value into the current stream .