public function testExtend()
 {
     $this->dictionary->extend('de');
     $result = $this->dictionary->get('example');
     $this->assertEquals('Was ist los?', $result['no_english_version']);
 }
Exemple #2
0
 /**
  * @param string $name
  *
  * @return mixed
  */
 public function get($name)
 {
     if (is_array($name)) {
         $retval = [];
         foreach ($name as $string) {
             $value = $this->get($string);
             if (is_object($value)) {
                 $value = $value->toArray();
             }
             if (!is_array($value)) {
                 $value = [$value];
             }
             $retval = array_merge($retval, $value);
         }
         return Dictionary::createDictionary($retval);
     }
     $parts = explode('.', $name, 2);
     $name = $parts[0];
     $seek = isset($parts[1]) ? $parts[1] : null;
     if (!empty($seek)) {
         $object = $this->offsetGet($name);
         $selfClass = __CLASS__;
         if ($object instanceof $selfClass) {
             /** @var self $object */
             return $object->get($seek);
         } else {
             if (is_array($object)) {
                 return $this->createDictionary($object)->get($seek);
             }
         }
     } else {
         return $this->offsetGet($name);
     }
     return null;
 }