for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sepia\PoParser\Catalog;
class CatalogArray implements Catalog
{
/** @var Headers */
protected $headers;
/** @var array */
protected $entries;
/**
* @param Entry[] $entries
*/
public function __construct(array $entries = array())
$this->entries = array();
$this->headers = new Headers();
foreach ($entries as $entry) {
$this->addEntry($entry);
}
* {@inheritdoc}
public function addEntry(Entry $entry)
$key = $this->getEntryHash(
$entry->getMsgId(),
$entry->getMsgCtxt()
);
$this->entries[$key] = $entry;
public function setHeaders(Headers $headers)
$this->headers = $headers;
public function removeEntry($msgid, $msgctxt = null)
$key = $this->getEntryHash($msgid, $msgctxt);
if (isset($this->entries[$key])) {
unset($this->entries[$key]);
public function getHeaders()
return $this->headers;
public function getEntries()
return $this->entries;
public function getEntry($msgId, $context = null)
$key = $this->getEntryHash($msgId, $context);
if (!isset($this->entries[$key])) {
return null;
return $this->entries[$key];
* @param string $msgId
* @param string|null $context
*
* @return string
private function getEntryHash($msgId, $context = null)
return md5($msgId.$context);