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);
        }
    }