/**
  * @since 2.5
  *
  * @param string $languageCode
  *
  * @return string
  */
 public function getFallbackLanguageBy($languageCode = '')
 {
     $languageCode = strtolower(trim($languageCode));
     if (isset($this->fallbackLanguages[$languageCode])) {
         return $this->fallbackLanguages[$languageCode];
     }
     $index = 'fallbackLanguage';
     // Unknown, use the default
     if ($languageCode === '') {
         return $this->canonicalFallbackLanguageCode;
     }
     try {
         $contents = $this->languageJsonFileContentsReader->readByLanguageCode($languageCode);
     } catch (RuntimeException $e) {
         $this->fallbackLanguages[$languageCode] = $this->canonicalFallbackLanguageCode;
     }
     // Get customized fallbackLanguage
     if (isset($contents[$index])) {
         $this->fallbackLanguages[$languageCode] = $contents[$index];
     }
     // The ultimate defense line, fallback was not set, or is false or empty
     // which means use the canonicalFallbackLanguageCode
     if (!isset($contents[$index]) || $this->fallbackLanguages[$languageCode] === false || $this->fallbackLanguages[$languageCode] === '') {
         $this->fallbackLanguages[$languageCode] = $this->canonicalFallbackLanguageCode;
     }
     return $this->fallbackLanguages[$languageCode];
 }
 private function getCanonicalContentsFrom($languageCode, $index)
 {
     // Last resort before throwing the towel, make sure we really have
     // something when the default FallbackLanguageCode is used
     if (!isset($this->contents[$languageCode][$index])) {
         $this->contents[$languageCode] = $this->languageJsonFileContentsReader->readByLanguageCode($languageCode, true);
     }
     if (isset($this->contents[$languageCode][$index])) {
         return $this->contents[$languageCode][$index];
     }
     throw new RuntimeException("Unknown or invalid `{$index}` index for `{$languageCode}`");
 }
 protected function tearDown()
 {
     $this->testEnvironment->tearDown();
     LanguageJsonFileContentsReader::clear();
     parent::tearDown();
 }
 /**
  * @dataProvider languageCodeProvider
  */
 public function testGetModificationTimeByLanguageCode($languageCode)
 {
     $instance = new LanguageJsonFileContentsReader();
     $this->assertInternalType('integer', $instance->getModificationTimeByLanguageCode($languageCode));
 }