Page MenuHomeDevCentral

D2538.diff
No OneTemporary

D2538.diff

diff --git a/src/Output/HTMLOutput.php b/src/Output/HTMLOutput.php
--- a/src/Output/HTMLOutput.php
+++ b/src/Output/HTMLOutput.php
@@ -15,48 +15,56 @@
public function render () : string {
$send = [];
- $title = $this->report->title;
- $send[] =
- '<h1 id="' . $this->makeId($title) . '">' . self::encode($title)
- . '</h1>';
+ if ($this->report->sections || $this->report->properties
+ || $this->report->title) {
- foreach ($this->report->sections as $section) {
- $title = $section->title;
+ $title = $this->report->title;
$send[] =
- '<h2 id="' . $this->makeId($title) . '">' .
- self::encode($title) . '</h2>';
- foreach ($section->entries as $entry) {
- $title = $entry->title;
- $send[] = '<h3 id="' . $this->makeId($title) . '">' .
- self::encode($title) . '</h3>';
+ '<h1 id="' . $this->makeId($title) . '">' . self::encode($title)
+ . '</h1>';
+ if ($this->report->sections) {
+ foreach ($this->report->sections as $section) {
+ $title = $section->title;
+ $send[] =
+ '<h2 id="' . $this->makeId($title) . '">' .
+ self::encode($title) . '</h2>';
+ foreach ($section->entries as $entry) {
+ $title = $entry->title;
+ $send[] = '<h3 id="' . $this->makeId($title) . '">' .
+ self::encode($title) . '</h3>';
- $text = explode("\n\n", $entry->text);
+ $text = explode("\n\n", $entry->text);
- foreach ($text as $value) {
- $send[] = '<p>' . self::encode($value) . '</p>';
+ foreach ($text as $value) {
+ $send[] = '<p>' . self::encode($value) . '</p>';
+ }
+ }
+ }
+ if ($this->report->properties && $this->report->sections) {
+ $send[] = '<hr>';
}
}
- }
- $send[] = '<hr>';
-
- $send[] = '<h2 id="report-properties">Report properties</h2>';
- $send[] = '<table>';
- $send[] = str_repeat(" ", 4) . '<tbody>';
+ if ($this->report->properties) {
+ $send[] = '<h2 id="report-properties">Report properties</h2>';
+ $send[] = '<table>';
+ $send[] = str_repeat(" ", 4) . '<tbody>';
- $properties = $this->report->properties;
+ $properties = $this->report->properties;
- foreach ($properties as $key => $value) {
- $send[] = str_repeat(" ", 4) . '<tr>';
- $send[] = str_repeat(" ", 8) .
+ foreach ($properties as $key => $value) {
+ $send[] = str_repeat(" ", 4) . '<tr>';
+ $send[] = str_repeat(" ", 8) .
- '<th>' . self::encode($key) . '</th>';
- $send[] = str_repeat(" ", 8) .
- '<td>' . self::encode($value) . '</td>';
+ '<th>' . self::encode($key) . '</th>';
+ $send[] = str_repeat(" ", 8) .
+ '<td>' . self::encode($value) . '</td>';
- $send[] = str_repeat(" ", 4) . '</tr>';
+ $send[] = str_repeat(" ", 4) . '</tr>';
+ }
+ $send[] = str_repeat(" ", 4) . '</tbody>';
+ $send[] = '</table>';
+ }
}
- $send[] = str_repeat(" ", 4) . '</tbody>';
- $send[] = '</table>';
$send[] = '';
return implode("\n", $send);
diff --git a/src/Output/MarkdownOutput.php b/src/Output/MarkdownOutput.php
--- a/src/Output/MarkdownOutput.php
+++ b/src/Output/MarkdownOutput.php
@@ -8,46 +8,61 @@
$send = [];
- $send[] = '# ' . $this->report->title;
- $send[] = '';
- foreach ($this->report->sections as $section) {
- $send[] = '## ' . $section->title;
+ if ($this->report->sections || $this->report->properties
+ || $this->report->title) {
+
+ $send[] = '# ' . $this->report->title;
$send[] = '';
- foreach ($section->entries as $entry) {
- $send[] = '### ' . $entry->title;
+ foreach ($this->report->sections as $section) {
+ $send[] = '## ' . $section->title;
$send[] = '';
- $send[] = $entry->text;
+ foreach ($section->entries as $entry) {
+
+ $send[] = '### ' . $entry->title;
+ $send[] = '';
+ $send[] = $entry->text;
+ $send[] = '';
+ }
+ }
+
+ if ($this->report->properties && $this->report->sections) {
+ $send[] = '---';
$send[] = '';
}
- }
+ if ($this->report->properties) {
+ $properties = $this->report->properties;
+ $propertyMaxLength = 0;
+ $maxValue = 0;
+ foreach ($properties as $key => $value) {
+ $propertyMaxLength = max($propertyMaxLength, strlen($key));
+ $maxValue = max($maxValue, strlen($value));
+ }
+ if ($propertyMaxLength < 8) {
+ $propertyMaxLength = 8;
+ }
- $send[] = '---';
- $send[] = '';
- $properties = $this->report->properties;
- $propertyMaxLength = 0;
- $maxValue = 0;
- foreach ($properties as $key => $value) {
- $propertyMaxLength = max($propertyMaxLength, strlen($key));
- $maxValue = max($maxValue, strlen($value));
- }
- $propertyMaxLength = max(8, $propertyMaxLength);
+ $send[] =
+ '| Property' . str_repeat(' ', $propertyMaxLength - 8)
+ . ' | '
+ . str_repeat(' ', $maxValue) . ' |';
- $send[] = '| Property' . str_repeat(' ', $propertyMaxLength - 8) . ' | '
- . str_repeat(' ', $maxValue) . ' |';
+ $send[] = '|' . str_repeat('-', $propertyMaxLength + 2) . '|'
+ . str_repeat('-', $maxValue + 2) . '|';
- $send[] = '|' . str_repeat('-', $propertyMaxLength + 2) . '|'
- . str_repeat('-', $maxValue + 2) . '|';
+ foreach ($properties as $key => $value) {
+ $send[] =
+ '| ' . $key . str_repeat(' ',
+ $propertyMaxLength - strlen($key))
+ . ' | '
+ . $value . str_repeat(' ', $maxValue - strlen($value))
+ . ' |';
+ }
- foreach ($properties as $key => $value) {
- $send[] =
- '| ' . $key . str_repeat(' ', $propertyMaxLength - strlen($key))
- . ' | '
- . $value . str_repeat(' ', $maxValue - strlen($value)) . ' |';
+ $send[] = '';
+ }
}
- $send[] = '';
-
return implode("\n", $send);
}
}
diff --git a/src/Output/XMLOutput.php b/src/Output/XMLOutput.php
--- a/src/Output/XMLOutput.php
+++ b/src/Output/XMLOutput.php
@@ -12,57 +12,66 @@
xmlwriter_set_indent($document, true);
xmlwriter_set_indent_string($document, ' ');
-
xmlwriter_start_document($document, '1.0', 'UTF-8');
xmlwriter_start_element($document, 'report');
xmlwriter_start_attribute($document, 'title');
- xmlwriter_text($document, $this->report->title);
- xmlwriter_end_attribute($document);
- foreach ($this->report->sections as $section) {
- xmlwriter_start_element($document, 'section');
- xmlwriter_start_attribute($document, 'title');
- xmlwriter_text($document, $section->title);
+ if ($this->report->sections || $this->report->properties
+ || $this->report->title) {
+
+ xmlwriter_text($document, $this->report->title);
xmlwriter_end_attribute($document);
- foreach ($section->entries as $entry) {
- xmlwriter_start_element($document, 'entry');
+ foreach ($this->report->sections as $section) {
+ xmlwriter_start_element($document, 'section');
xmlwriter_start_attribute($document, 'title');
- xmlwriter_text($document, $entry->title);
+ xmlwriter_text($document, $section->title);
xmlwriter_end_attribute($document);
- xmlwriter_start_element($document, 'text');
- xmlwriter_text($document, $entry->text);
- xmlwriter_end_element($document);
+ foreach ($section->entries as $entry) {
+ xmlwriter_start_element($document, 'entry');
+
+ xmlwriter_start_attribute($document, 'title');
+ xmlwriter_text($document, $entry->title);
+ xmlwriter_end_attribute($document);
+
+ xmlwriter_start_element($document, 'text');
+ xmlwriter_text($document, $entry->text);
+ xmlwriter_end_element($document);
- xmlwriter_end_element($document);
+ xmlwriter_end_element($document);
+ }
+ xmlwriter_end_element($document); // section
}
- xmlwriter_end_element($document); // section
- }
- xmlwriter_start_element($document, 'data');
- xmlwriter_start_attribute($document, 'title');
- xmlwriter_text($document, "Properties");
- xmlwriter_end_attribute($document);
- foreach ($this->report->properties as $key => $value) {
- xmlwriter_start_element($document, 'entry');
+ if ($this->report->properties) {
- xmlwriter_start_element($document, 'key');
- xmlwriter_text($document, $key);
- xmlwriter_end_element($document);
+ xmlwriter_start_element($document, 'data');
+ xmlwriter_start_attribute($document, 'title');
+ xmlwriter_text($document, "Properties");
+ xmlwriter_end_attribute($document);
- xmlwriter_start_element($document, 'value');
- xmlwriter_text($document, $value);
- xmlwriter_end_element($document);
+ foreach ($this->report->properties as $key => $value) {
+ xmlwriter_start_element($document, 'entry');
- xmlwriter_end_element($document);
- }
- xmlwriter_end_element($document); // data
+ xmlwriter_start_element($document, 'key');
+ xmlwriter_text($document, $key);
+ xmlwriter_end_element($document);
+
+ xmlwriter_start_element($document, 'value');
+ xmlwriter_text($document, $value);
+ xmlwriter_end_element($document);
- xmlwriter_end_element($document); // report
+ xmlwriter_end_element($document);
+ }
+ xmlwriter_end_element($document); // data
+
+ xmlwriter_end_element($document);// report
+ }
+ }
xmlwriter_end_document($document);
return xmlwriter_output_memory($document);

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 02:02 (9 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2314378
Default Alt Text
D2538.diff (11 KB)

Event Timeline