Ejemplo n.º 1
0
 /**
  * @return array[]
  */
 public function getNestedValues() : array
 {
     $values = [];
     foreach ($this->data->getIndexes($this->key) as $index) {
         $key = $this->key . '[' . $index . ']';
         if ($this->data->hasKey($key)) {
             $values[] = $this->data->getValue($key);
         }
     }
     return $values;
 }
Ejemplo n.º 2
0
 public function bind(Data $data) : BindResult
 {
     $values = [];
     $formErrorSequence = new FormErrorSequence();
     foreach ($data->getIndexes($this->key) as $index) {
         $bindResult = $this->wrappedMapping->withPrefixAndRelativeKey($this->key, $index)->bind($data);
         if (!$bindResult->isSuccess()) {
             $formErrorSequence = $formErrorSequence->merge($bindResult->getFormErrorSequence());
             continue;
         }
         $values[] = $bindResult->getValue();
     }
     if (!$formErrorSequence->isEmpty()) {
         return BindResult::fromFormErrorSequence($formErrorSequence);
     }
     return $this->applyConstraints($values, $this->key);
 }