Example #1
0
 /**
  * @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());
 }
Example #2
0
 /**
  * @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;
 }
Example #3
0
 /**
  * @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));
 }