Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 20 |
| PoMemoryWriter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
182 | |
0.00% |
0 / 20 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| writeItem | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 7 |
|||
| writeItems | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 5 |
|||
| getData | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| setLangcode | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getLangcode | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getHeader | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| setHeader | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\Component\Gettext\PoMemoryWriter. | |
| */ | |
| namespace Drupal\Component\Gettext; | |
| /** | |
| * Defines a Gettext PO memory writer, to be used by the installer. | |
| */ | |
| class PoMemoryWriter implements PoWriterInterface { | |
| /** | |
| * Array to hold all PoItem elements. | |
| * | |
| * @var array | |
| */ | |
| private $_items; | |
| /** | |
| * Constructor, initialize empty items. | |
| */ | |
| function __construct() { | |
| $this->_items = array(); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function writeItem(PoItem $item) { | |
| if (is_array($item->getSource())) { | |
| $item->setSource(implode(LOCALE_PLURAL_DELIMITER, $item->getSource())); | |
| $item->setTranslation(implode(LOCALE_PLURAL_DELIMITER, $item->getTranslation())); | |
| } | |
| $context = $item->getContext(); | |
| $this->_items[$context != NULL ? $context : ''][$item->getSource()] = $item->getTranslation(); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function writeItems(PoReaderInterface $reader, $count = -1) { | |
| $forever = $count == -1; | |
| while (($count-- > 0 || $forever) && ($item = $reader->readItem())) { | |
| $this->writeItem($item); | |
| } | |
| } | |
| /** | |
| * Get all stored PoItem's. | |
| * | |
| * @return array PoItem | |
| */ | |
| public function getData() { | |
| return $this->_items; | |
| } | |
| /** | |
| * Implements Drupal\Component\Gettext\PoMetadataInterface:setLangcode(). | |
| * | |
| * Not implemented. Not relevant for the MemoryWriter. | |
| */ | |
| function setLangcode($langcode) { | |
| } | |
| /** | |
| * Implements Drupal\Component\Gettext\PoMetadataInterface:getLangcode(). | |
| * | |
| * Not implemented. Not relevant for the MemoryWriter. | |
| */ | |
| function getLangcode() { | |
| } | |
| /** | |
| * Implements Drupal\Component\Gettext\PoMetadataInterface:getHeader(). | |
| * | |
| * Not implemented. Not relevant for the MemoryWriter. | |
| */ | |
| function getHeader() { | |
| } | |
| /** | |
| * Implements Drupal\Component\Gettext\PoMetadataInterface:setHeader(). | |
| * | |
| * Not implemented. Not relevant for the MemoryWriter. | |
| */ | |
| function setHeader(PoHeader $header) { | |
| } | |
| } |