TidyFilter::read PHP Method

read() public method

Reads input and returns Tidy-filtered output.
public read ( $len = null ) : the
return the resulting stream, or -1 if the end of the resulting stream has been reached
    function read($len = null)
    {
        if (!class_exists('Tidy')) {
            throw new BuildException("You must enable the 'tidy' extension in your PHP configuration in order to use the Tidy filter.");
        }
        if (!$this->getInitialized()) {
            $this->_initialize();
            $this->setInitialized(true);
        }
        $buffer = $this->in->read($len);
        if ($buffer === -1) {
            return -1;
        }
        $config = $this->getDistilledConfig();
        $tidy = new Tidy();
        $tidy->parseString($buffer, $config, $this->encoding);
        $tidy->cleanRepair();
        return tidy_get_output($tidy);
    }