3 declare(strict_types = 1);
20 use enshrined\svgSanitize\Sanitizer;
29 public function sanitizeFile(
string $sourcePath,
string $targetPath =
null): void
31 if ($targetPath ===
null) {
32 $targetPath = $sourcePath;
34 $svg = file_get_contents($sourcePath);
35 if (!is_string($svg)) {
39 if ($sanitizedSvg !== $svg) {
40 file_put_contents($targetPath, $sanitizedSvg);
52 $sanitizer =
new Sanitizer();
53 $sanitizer->removeRemoteReferences(
true);
54 return $sanitizer->sanitize($svg) ?:
'';