Esempio n. 1
0
 public static function fromString(string $type, Types $types) : TypeInterface
 {
     $type = new Str($type);
     if (!$type->match(self::PATTERN)) {
         throw new InvalidArgumentException();
     }
     $matches = $type->getMatches(self::PATTERN);
     return new self($types->build((string) $matches->get('key')), $types->build((string) $matches->get('value')));
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public static function fromConfig(MapInterface $config, Types $types) : TypeInterface
 {
     if ((string) $config->keyType() !== 'scalar' || (string) $config->valueType() !== 'variable') {
         throw new InvalidArgumentException();
     }
     $type = new self();
     $type->innerKey = $config->get('key');
     $type->innerValue = $config->get('inner');
     $type->inner = $types->build($config->get('inner'), $config->remove('inner')->remove('key'));
     $type->key = $types->build($config->get('key'), $config->remove('inner')->remove('key'));
     return $type;
 }