DataSift\Storyplayer\OutputLib\CodeFormatter::formatCode PHP Method

formatCode() public static method

public static formatCode ( $parsedCode )
    public static function formatCode($parsedCode)
    {
        // special case - make sure we have code to format
        if ($parsedCode === null) {
            return 'no code' . PHP_EOL;
        }
        // we have the parsed code
        // we're going to need something to turn the parsed code back
        // into source code
        $prettyPrinter = new \PhpParser\PrettyPrinter\Standard();
        // convert the parsed code into a string
        //
        // this string may contain more than just the code we are
        // interested in
        $codeToPrint = $prettyPrinter->prettyPrint([$parsedCode]);
        // let's strip stuff
        $codeToPrint = self::stripComments($codeToPrint);
        // all done
        return $codeToPrint;
    }