public function setAt($offset, $data, $options = [])
    {
        $keys = is_array($offset) ? $offset : ($offset !== null ? explode('.', $offset) : []);

        $name = array_shift($keys);

        if ($keys) {
          $this->get($name)->setAt($keys, $data, $options);
        }

        if ($schema = $this->schema()) {
            $data = $schema->cast(null, $data, [
                'exists'    => isset($options['exists']) ? $options['exists'] : null,
                'parent'    => $this,
                'basePath'  => $this->basePath(),
                'defaults'  => true
            ]);
        }
        if ($name !== null) {
            if (!is_numeric($name)) {
                throw new ORMException("Invalid index `" . $name . "` for a collection, must be a numeric value.");
            }
            $previous = isset($this->_data[$name]) ? $this->_data[$name] : null;
            $this->_data[$name] = $data;
            if ($previous instanceof HasParentsInterface) {
                $previous->unsetParent($this);
            }
        } else {
            $this->_data[] = $data;
            $name = key($this->_data);
        }
        if ($data instanceof HasParentsInterface) {
            $data->setParent($this, $name);
        }
        $this->_modified = true;
        return $this;
    }
public function setAt($offset, $data, $options = [])
    {
        $keys = is_array($offset) ? $offset : ($offset !== null ? explode('.', $offset) : []);

        $name = array_shift($keys);

        if ($keys) {
          $this->get($name)->setAt($keys, $data, $options);
        }

        if ($schema = $this->schema()) {
            $data = $schema->cast(null, $data, [
                'exists'    => isset($options['exists']) ? $options['exists'] : null,
                'parent'    => $this,
                'basePath'  => $this->basePath(),
                'defaults'  => true
            ]);
        }
        if ($name !== null) {
            if (!is_numeric($name)) {
                throw new ORMException("Invalid index `" . $name . "` for a collection, must be a numeric value.");
            }
            $previous = isset($this->_data[$name]) ? $this->_data[$name] : null;
            $this->_data[$name] = $data;
            if ($previous instanceof HasParentsInterface) {
                $previous->unsetParent($this);
            }
        } else {
            $this->_data[] = $data;
            $name = key($this->_data);
        }
        if ($data instanceof HasParentsInterface) {
            $data->setParent($this, $name);
        }
        $this->_modified = true;
        return $this;
    }
public function setAt ( $ offset , $ data , $ options = [ ] ) { $ keys = is_array ( $ offset ) ? $ offset : ( $ offset !== null ? explode ( '.' , $ offset ) : [ ] ) ; $ name = array_shift ( $ keys ) ; if ( $ keys ) { $ this -> get ( $ name ) -> setAt ( $ keys , $ data , $ options ) ; } if ( $ schema = $ this -> schema ( ) ) { $ data = $ schema -> cast ( null , $ data , [ 'exists' => isset ( $ options [ 'exists' ] ) ? $ options [ 'exists' ] : null , 'parent' => $ this , 'basePath' => $ this -> basePath ( ) , 'defaults' => true ] ) ; } if ( $ name !== null ) { if ( ! is_numeric ( $ name ) ) { throw new ORMException ( "Invalid index `" . $ name . "` for a collection, must be a numeric value." ) ; } $ previous = isset ( $ this -> _data [ $ name ] ) ? $ this -> _data [ $ name ] : null ; $ this -> _data [ $ name ] = $ data ; if ( $ previous instanceof HasParentsInterface ) { $ previous -> unsetParent ( $ this ) ; } } else { $ this -> _data [ ] = $ data ; $ name = key ( $ this -> _data ) ; } if ( $ data instanceof HasParentsInterface ) { $ data -> setParent ( $ this , $ name ) ; } $ this -> _modified = true ; return $ this ; }
Sets data inside the `Collection` instance.

@param  mixed $offset  The offset.
@param  mixed $data    The entity object or data to set.
@param  array $options Method options:
- `'exists'` _boolean_: Determines whether or not this entity exists
@return mixed          Returns `$this`.
Sets data inside the Collection instance .