$Entries */ class Feed{ public string $Url; public string $Title; public $Entries = []; public string $Path; public ?string $Stylesheet = null; protected ?string $XmlString = null; /** * @param string $title * @param string $url * @param string $path * @param array $entries */ public function __construct(string $title, string $url, string $path, array $entries){ $this->Url = $url; $this->Title = $title; $this->Path = $path; $this->Entries = $entries; } // ******* // METHODS // ******* protected function CleanXmlString(string $xmlString): string{ $tempFilename = tempnam('/tmp/', 'se-'); file_put_contents($tempFilename, $xmlString); exec('se clean ' . escapeshellarg($tempFilename) . ' 2>&1', $output); // Capture the result in case there's an error, otherwise it prints to stdout $output = file_get_contents($tempFilename); unlink($tempFilename); // At the moment, `se clean` strips stylesheet declarations. Restore them here. if($this->Stylesheet !== null){ $output = str_replace("", "\nStylesheet . "\" type=\"text/xsl\"?>", $output); } return $output; } protected function GetXmlString(): string{ // Virtual function, meant to be implemented by subclass return ''; } public function Save(): void{ $feed = $this->GetXmlString(); file_put_contents($this->Path, $feed); } }