1 | <?php |
||
36 | class XMLWriter extends \XMLWriter |
||
37 | { |
||
38 | /** Temporary storage method */ |
||
39 | const STORAGE_MEMORY = 1; |
||
40 | const STORAGE_DISK = 2; |
||
41 | |||
42 | /** |
||
43 | * Temporary filename |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | private $tempFileName = ''; |
||
48 | |||
49 | /** |
||
50 | * Create a new \PhpOffice\PhpPowerpoint\Shared\XMLWriter instance |
||
51 | * |
||
52 | * @param int $pTemporaryStorage Temporary storage location |
||
53 | * @param string $pTemporaryStorageDir Temporary storage folder |
||
54 | */ |
||
55 | 1 | public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageDir = null, $compatibility = false) |
|
79 | |||
80 | /** |
||
81 | * Destructor |
||
82 | */ |
||
83 | 1 | public function __destruct() |
|
93 | |||
94 | /** |
||
95 | * Get written data |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | 1 | public function getData() |
|
100 | { |
||
101 | 1 | if ($this->tempFileName == '') { |
|
102 | 1 | return $this->outputMemory(true); |
|
103 | } |
||
104 | |||
105 | 1 | $this->flush(); |
|
106 | 1 | return file_get_contents($this->tempFileName); |
|
107 | } |
||
108 | |||
109 | |||
110 | /** |
||
111 | * Write simple element and attribute(s) block |
||
112 | * |
||
113 | * There are two options: |
||
114 | * 1. If the `$attributes` is an array, then it's an associative array of attributes |
||
115 | * 2. If not, then it's a simple attribute-value pair |
||
116 | * |
||
117 | * @param string $element |
||
118 | * @param string|array $attributes |
||
119 | * @param string $value |
||
120 | * @return void |
||
121 | */ |
||
122 | public function writeElementBlock($element, $attributes, $value = null) |
||
133 | |||
134 | /** |
||
135 | * Write element if ... |
||
136 | * |
||
137 | * @param bool $condition |
||
138 | * @param string $element |
||
139 | * @param string $attribute |
||
140 | * @param mixed $value |
||
141 | * @return void |
||
142 | */ |
||
143 | public function writeElementIf($condition, $element, $attribute = null, $value = null) |
||
155 | |||
156 | /** |
||
157 | * Write attribute if ... |
||
158 | * |
||
159 | * @param bool $condition |
||
160 | * @param string $attribute |
||
161 | * @param mixed $value |
||
162 | * @return void |
||
163 | */ |
||
164 | public function writeAttributeIf($condition, $attribute, $value) |
||
170 | } |
||
171 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.