| Total Complexity | 11 |
| Total Lines | 89 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class CatalogArray implements Catalog |
||
| 6 | { |
||
| 7 | /** @var Headers */ |
||
| 8 | protected $headers; |
||
| 9 | |||
| 10 | /** @var array */ |
||
| 11 | protected $entries; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @param Entry[] $entries |
||
| 15 | */ |
||
| 16 | public function __construct(array $entries = array()) |
||
| 17 | { |
||
| 18 | $this->entries = array(); |
||
| 19 | $this->headers = new Headers(); |
||
| 20 | foreach ($entries as $entry) { |
||
| 21 | $this->addEntry($entry); |
||
| 22 | } |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * {@inheritdoc} |
||
| 27 | */ |
||
| 28 | public function addEntry(Entry $entry) |
||
| 29 | { |
||
| 30 | $key = $this->getEntryHash( |
||
| 31 | $entry->getMsgId(), |
||
| 32 | $entry->getMsgCtxt() |
||
| 33 | ); |
||
| 34 | $this->entries[$key] = $entry; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * {@inheritdoc} |
||
| 39 | */ |
||
| 40 | public function setHeaders(Headers $headers) |
||
| 41 | { |
||
| 42 | $this->headers = $headers; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * {@inheritdoc} |
||
| 47 | */ |
||
| 48 | public function removeEntry($msgid, $msgctxt = null) |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritdoc} |
||
| 58 | */ |
||
| 59 | public function getHeaders() |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * {@inheritdoc} |
||
| 66 | */ |
||
| 67 | public function getEntries() |
||
| 68 | { |
||
| 69 | return $this->entries; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * {@inheritdoc} |
||
| 74 | */ |
||
| 75 | public function getEntry($msgId, $context = null) |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @param string $msgId |
||
| 87 | * @param string|null $context |
||
| 88 | * |
||
| 89 | * @return string |
||
| 90 | */ |
||
| 91 | private function getEntryHash($msgId, $context = null) |
||
| 94 | } |
||
| 95 | } |
||
| 96 |