Naneau\Obfuscator\Obfuscator::obfuscateFileContents PHP Method

obfuscateFileContents() private method

Obfuscate a single file's contents
private obfuscateFileContents ( string $file, boolean $ignoreError ) : string
$file string
$ignoreError boolean if true, do not throw an Error and exit, but continue with next file
return string obfuscated contents
    private function obfuscateFileContents($file, $ignoreError)
    {
        try {
            // Input code
            $source = php_strip_whitespace($file);
            // Get AST
            $ast = $this->getTraverser()->traverse($this->getParser()->parse($source));
            return "<?php\n" . $this->getPrettyPrinter()->prettyPrint($ast);
        } catch (Exception $e) {
            if ($ignoreError) {
                sprintf('Could not parse file "%s"', $file);
                $this->getEventDispatcher()->dispatch('obfuscator.file.error', new FileErrorEvent($file, $e->getMessage()));
            } else {
                throw new Exception(sprintf('Could not parse file "%s"', $file), null, $e);
            }
        }
    }