/** * @param TranslationMapInterface $map * @return string */ private function extractFromFallbacks(TranslationMapInterface $map) { $english = Language::get('en'); if ($map->has($english)) { return $map->get($english); } $translations = $map->getAll(); reset($translations); /** @var TranslationInterface $translation */ $translation = current($translations); return $map->get($translation->getLanguage()); }
/** * @param TranslationMapInterface $other * @return boolean */ public function equals(TranslationMapInterface $other) { if ($this === $other) { return true; } $otherData = $other->getAll(); if (count($this->translations) !== count($otherData)) { return false; } foreach ($this->translations as $translation) { if (!$other->has($translation->getLanguage())) { return false; } if ($other->get($translation->getLanguage()) !== $translation->getText()) { return false; } } return true; }
/** * @param TranslationMapInterface $a * @param TranslationMapInterface $b * @param boolean $equal * @dataProvider equalsData */ public function testEquals(TranslationMapInterface $a, TranslationMapInterface $b, $equal) { $this->assertEquals($equal, $a->equals($b)); $this->assertEquals($equal, $b->equals($a)); }