addReport($reports); } /** * Adds a report to this property * * The report must be a string in clark-notation. * Multiple reports can be specified as an array. * * @param mixed $report * @return void */ function addReport($report) { $report = (array)$report; foreach ($report as $r) { if (!preg_match('/^{([^}]*)}(.*)$/', $r)) throw new DAV\Exception('Reportname must be in clark-notation'); $this->reports[] = $r; } } /** * Returns the list of supported reports * * @return string[] */ function getValue() { return $this->reports; } /** * Returns true or false if the property contains a specific report. * * @param string $reportName * @return bool */ function has($reportName) { return in_array( $reportName, $this->reports ); } /** * The xmlSerialize metod is called during xml writing. * * Use the $writer argument to write its own xml serialization. * * An important note: do _not_ create a parent element. Any element * implementing XmlSerializble should only ever write what's considered * its 'inner xml'. * * The parent of the current element is responsible for writing a * containing element. * * This allows serializers to be re-used for different element names. * * If you are opening new elements, you must also close them again. * * @param Writer $writer * @return void */ function xmlSerialize(Writer $writer) { foreach ($this->getValue() as $val) { $writer->startElement('{DAV:}supported-report'); $writer->startElement('{DAV:}report'); $writer->writeElement($val); $writer->endElement(); $writer->endElement(); } } /** * Generate html representation for this value. * * The html output is 100% trusted, and no effort is being made to sanitize * it. It's up to the implementor to sanitize user provided values. * * The output must be in UTF-8. * * The baseUri parameter is a url to the root of the application, and can * be used to construct local links. * * @param HtmlOutputHelper $html * @return string */ function toHtml(HtmlOutputHelper $html) { return implode( ', ', array_map([$html, 'xmlName'], $this->getValue()) ); } }