public function render($file, $id = '')
    {
        if (empty($id) === true) {
            $id = uniqid();
        }

        $this->init($id, $file);

        $stream = $this->getStream();

        while ($stream->eof() === false) {

            try {
                $char = $stream->read(1);
                $this->beforeCharReading($char);

                switch ($this->getState()) {
                    case self::RUNNING:
                        $this->runningState();
                    break;

                    case self::IN_ATRULE:
                        $this->inAtRuleState();
                    break;

                    case self::IN_ATRULESTRING:
                        $this->inAtRuleStringState();
                    break;

                    case self::IN_SELECTOR:
                        $this->inSelectorState();
                    break;

                    case self::IN_CLASSBODY:
                        $this->inClassbodyState();
                    break;

                    case self::IN_MAINCOMMENT:
                        $this->inMainCommentState();
                    break;

                    case self::IN_CLASSSTRING:
                        $this->inClassStringState();
                    break;

                    case self::IN_CLASSCOMMENT:
                        $this->inClassCommentState();
                    break;

                    case self::IN_ATRULEBODY:
                        $this->inAtRuleBodyState();
                    break;
                }

                $this->afterCharReading($char);
            } catch (MemoryStreamException $e) {
                $stream->close();
                $msg = "An unexpected error occured while reading the CSS file '${file}'.";
                throw new RenderingException($msg, RenderingException::RUNTIME, $e);
            }
        }

        $stream->close();

        return $this->getOutput();
    }
public function render($file, $id = '')
    {
        if (empty($id) === true) {
            $id = uniqid();
        }

        $this->init($id, $file);

        $stream = $this->getStream();

        while ($stream->eof() === false) {

            try {
                $char = $stream->read(1);
                $this->beforeCharReading($char);

                switch ($this->getState()) {
                    case self::RUNNING:
                        $this->runningState();
                    break;

                    case self::IN_ATRULE:
                        $this->inAtRuleState();
                    break;

                    case self::IN_ATRULESTRING:
                        $this->inAtRuleStringState();
                    break;

                    case self::IN_SELECTOR:
                        $this->inSelectorState();
                    break;

                    case self::IN_CLASSBODY:
                        $this->inClassbodyState();
                    break;

                    case self::IN_MAINCOMMENT:
                        $this->inMainCommentState();
                    break;

                    case self::IN_CLASSSTRING:
                        $this->inClassStringState();
                    break;

                    case self::IN_CLASSCOMMENT:
                        $this->inClassCommentState();
                    break;

                    case self::IN_ATRULEBODY:
                        $this->inAtRuleBodyState();
                    break;
                }

                $this->afterCharReading($char);
            } catch (MemoryStreamException $e) {
                $stream->close();
                $msg = "An unexpected error occured while reading the CSS file '${file}'.";
                throw new RenderingException($msg, RenderingException::RUNTIME, $e);
            }
        }

        $stream->close();

        return $this->getOutput();
    }
public function render ( $ file , $ id = '' ) { if ( empty ( $ id ) === true ) { $ id = uniqid ( ) ; } $ this -> init ( $ id , $ file ) ; $ stream = $ this -> getStream ( ) ; while ( $ stream -> eof ( ) === false ) { try { $ char = $ stream -> read ( 1 ) ; $ this -> beforeCharReading ( $ char ) ; switch ( $ this -> getState ( ) ) { case self :: RUNNING : $ this -> runningState ( ) ; break ; case self :: IN_ATRULE : $ this -> inAtRuleState ( ) ; break ; case self :: IN_ATRULESTRING : $ this -> inAtRuleStringState ( ) ; break ; case self :: IN_SELECTOR : $ this -> inSelectorState ( ) ; break ; case self :: IN_CLASSBODY : $ this -> inClassbodyState ( ) ; break ; case self :: IN_MAINCOMMENT : $ this -> inMainCommentState ( ) ; break ; case self :: IN_CLASSSTRING : $ this -> inClassStringState ( ) ; break ; case self :: IN_CLASSCOMMENT : $ this -> inClassCommentState ( ) ; break ; case self :: IN_ATRULEBODY : $ this -> inAtRuleBodyState ( ) ; break ; } $ this -> afterCharReading ( $ char ) ; } catch ( MemoryStreamException $ e ) { $ stream -> close ( ) ; $ msg = "An unexpected error occured while reading the CSS file '${file}'." ; throw new RenderingException ( $ msg , RenderingException :: RUNTIME , $ e ) ; } } $ stream -> close ( ) ; return $ this -> getOutput ( ) ; }
Rescope the content of a given CSS file.

@param string $file The path to the file that has to be rescoped.
@param string $id The scope identifier. If not given, will be randomly generated.
@return string The rescoped content of $file.
@throws \qtism\runtime\rendering\RenderingException If something goes wrong while rescoping the content.
Rescope the content of a given CSS file .