preserveWhiteSpace = false; return $doc; } /** * Get text from path * * @param string $relativePath * @return string */ protected static function getText( string $relativePath ) : string { return file_get_contents( __DIR__ . '/../' . $relativePath ); } /** * Write text to path * * @param string $relativePath * @param string $text */ protected static function overwriteTextFile( string $relativePath, string $text ) : void { file_put_contents( __DIR__ . '/../' . $relativePath, $text ); } /** * Get parsed JSON from path * * @param string $relativePath * @param bool $assoc See json_decode() * @return array */ protected static function getJson( string $relativePath, bool $assoc = true ) : array { $json = json_decode( file_get_contents( __DIR__ . '/' . $relativePath ), $assoc ); return $json; } /** * Write JSON to path * * @param string $relativePath * @param array $data */ protected static function overwriteJsonFile( string $relativePath, array $data ) : void { $json = json_encode( $data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); // Tabs instead of 4 spaces $json = preg_replace( '/(?:\G|^) {4}/m', "\t", $json ); file_put_contents( __DIR__ . '/' . $relativePath, $json . "\n" ); } /** * Get HTML from path * * @param string $relativePath * @return string */ protected static function getHtml( string $relativePath ) : string { $html = file_get_contents( __DIR__ . '/../' . $relativePath ); // Remove all but the body tags from full Parsoid docs if ( strpos( $html, '
]*>)(.*)()`s', $html, $match ); $html = "