for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sepia\PoParser\Catalog;
class EntryFactory
{
/**
* @param array $entryArray
* @return Entry
*/
public static function createFromArray(array $entryArray)
$entry = new Entry(
$entryArray['msgid'],
isset($entryArray['msgstr']) ? $entryArray['msgstr'] : null
);
$plurals = array();
foreach ($entryArray as $key => $value) {
switch (true) {
case $key === 'msgctxt':
$entry->setMsgCtxt($entryArray['msgctxt']);
break;
case $key === 'flags':
$entry->setFlags($entryArray['flags']);
case $key === 'reference':
$entry->setReference($entryArray['reference']);
case $key === 'previous':
$entry->setPreviousEntry(self::createFromArray($entryArray['previous']));
case $key === 'tcomment':
$entry->setTranslatorComments($value);
case $key === 'ccomment':
$entry->setDeveloperComments($value);
case $key === 'obsolete':
$entry->setObsolete(true);
case 0 === strpos($key, 'msgstr['):
$plurals[] = $value;
}
if (count($plurals) > 0) {
$entry->setMsgStrPlurals($plurals);
return $entry;