public function isValid( &$errors = null, $throwException = false )
    {

        // open pipe
        $descriptorSpec = array(
            0 => array('pipe', 'r'),
            1 => array('pipe', 'w'),
            2 => array('pipe', 'w'),
        );

        $process = proc_open('php -l', $descriptorSpec, $pipes);

        if (!is_resource($process)) {
            throw new \Exception('Could not open PHP');
        }
        fwrite($pipes[0], $this->php);
        fclose($pipes[0]);

        $errors = stream_get_contents($pipes[2]);
        fclose($pipes[2]);

        $returnValue = proc_close($process);

        if( $throwException && $returnValue !== 0 ) {
            throw new BadPhpException($errors);
        }

        return $returnValue === 0;

    }