Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Component/Gettext/PoStreamWriter.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
79 } | 79 } |
80 | 80 |
81 /** | 81 /** |
82 * Implements Drupal\Component\Gettext\PoStreamInterface::close(). | 82 * Implements Drupal\Component\Gettext\PoStreamInterface::close(). |
83 * | 83 * |
84 * @throws Exception | 84 * @throws \Exception |
85 * If the stream is not open. | 85 * If the stream is not open. |
86 */ | 86 */ |
87 public function close() { | 87 public function close() { |
88 if ($this->_fd) { | 88 if ($this->_fd) { |
89 fclose($this->_fd); | 89 fclose($this->_fd); |
90 } | 90 } |
91 else { | 91 else { |
92 throw new Exception('Cannot close stream that is not open.'); | 92 throw new \Exception('Cannot close stream that is not open.'); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 /** | 96 /** |
97 * Write data to the stream. | 97 * Write data to the stream. |
98 * | 98 * |
99 * @param string $data | 99 * @param string $data |
100 * Piece of string to write to the stream. If the value is not directly a | 100 * Piece of string to write to the stream. If the value is not directly a |
101 * string, casting will happen in writing. | 101 * string, casting will happen in writing. |
102 * | 102 * |
103 * @throws Exception | 103 * @throws \Exception |
104 * If writing the data is not possible. | 104 * If writing the data is not possible. |
105 */ | 105 */ |
106 private function write($data) { | 106 private function write($data) { |
107 $result = fwrite($this->_fd, $data); | 107 $result = fwrite($this->_fd, $data); |
108 if ($result === FALSE) { | 108 if ($result === FALSE || $result != strlen($data)) { |
109 throw new Exception('Unable to write data: ' . substr($data, 0, 20)); | 109 throw new \Exception('Unable to write data: ' . substr($data, 0, 20)); |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 /** | 113 /** |
114 * Write the PO header to the stream. | 114 * Write the PO header to the stream. |
135 } | 135 } |
136 | 136 |
137 /** | 137 /** |
138 * Implements Drupal\Component\Gettext\PoStreamInterface::getURI(). | 138 * Implements Drupal\Component\Gettext\PoStreamInterface::getURI(). |
139 * | 139 * |
140 * @throws Exception | 140 * @throws \Exception |
141 * If the URI is not set. | 141 * If the URI is not set. |
142 */ | 142 */ |
143 public function getURI() { | 143 public function getURI() { |
144 if (empty($this->_uri)) { | 144 if (empty($this->_uri)) { |
145 throw new Exception('No URI set.'); | 145 throw new \Exception('No URI set.'); |
146 } | 146 } |
147 return $this->_uri; | 147 return $this->_uri; |
148 } | 148 } |
149 | 149 |
150 /** | 150 /** |