*
* @var string
*/
- private $_uri;
+ protected $uri;
/**
* The Gettext PO header.
*
* @var \Drupal\Component\Gettext\PoHeader
*/
- private $_header;
+ protected $header;
/**
* File handle of the current PO stream.
*
* @var resource
*/
- private $_fd;
+ protected $fd;
+
+ /**
+ * The language code of this writer.
+ *
+ * @var string
+ */
+ protected $langcode;
/**
* Gets the PO header of the current stream.
* The Gettext PO header.
*/
public function getHeader() {
- return $this->_header;
+ return $this->header;
}
/**
* The Gettext PO header to set.
*/
public function setHeader(PoHeader $header) {
- $this->_header = $header;
+ $this->header = $header;
}
/**
* The language code.
*/
public function getLangcode() {
- return $this->_langcode;
+ return $this->langcode;
}
/**
* The language code.
*/
public function setLangcode($langcode) {
- $this->_langcode = $langcode;
+ $this->langcode = $langcode;
}
/**
*/
public function open() {
// Open in write mode. Will overwrite the stream if it already exists.
- $this->_fd = fopen($this->getURI(), 'w');
+ $this->fd = fopen($this->getURI(), 'w');
// Write the header at the start.
$this->writeHeader();
}
* If the stream is not open.
*/
public function close() {
- if ($this->_fd) {
- fclose($this->_fd);
+ if ($this->fd) {
+ fclose($this->fd);
}
else {
throw new \Exception('Cannot close stream that is not open.');
* If writing the data is not possible.
*/
private function write($data) {
- $result = fwrite($this->_fd, $data);
+ $result = fwrite($this->fd, $data);
if ($result === FALSE || $result != strlen($data)) {
throw new \Exception('Unable to write data: ' . substr($data, 0, 20));
}
* Write the PO header to the stream.
*/
private function writeHeader() {
- $this->write($this->_header);
+ $this->write($this->header);
}
/**
* If the URI is not set.
*/
public function getURI() {
- if (empty($this->_uri)) {
+ if (empty($this->uri)) {
throw new \Exception('No URI set.');
}
- return $this->_uri;
+ return $this->uri;
}
/**
* {@inheritdoc}
*/
public function setURI($uri) {
- $this->_uri = $uri;
+ $this->uri = $uri;
}
}