src/GeneratorCollection.php
public function put($key, $value): CollectionInterface
    {
        return $this->wrap(function (Iterator $data) use ($key, $value) {
            $replaced = false;

            foreach ($data as $dataKey => $datum) {
                if ($key === $dataKey) {
                    yield $key => $value;
                    $replaced = true;
                } else {
                    yield $dataKey => $datum;
                }
            }

            if (!$replaced) {
                yield $key => $value;
            }
        });
    }
public function put($key, $value): CollectionInterface
    {
        return $this->wrap(function (Iterator $data) use ($key, $value) {
            $replaced = false;

            foreach ($data as $dataKey => $datum) {
                if ($key === $dataKey) {
                    yield $key => $value;
                    $replaced = true;
                } else {
                    yield $dataKey => $datum;
                }
            }

            if (!$replaced) {
                yield $key => $value;
            }
        });
    }
public function put ( $ key , $ value ) : CollectionInterface { return $ this -> wrap ( function ( Iterator $ data ) use ( $ key , $ value ) { $ replaced = false ; foreach ( $ data as $ dataKey => $ datum ) { if ( $ key === $ dataKey ) { yield $ key => $ value ; $ replaced = true ; } else { yield $ dataKey => $ datum ; } } if ( ! $ replaced ) { yield $ key => $ value ; } } ) ; }
Put an item in the collection by key.

@param  mixed $key
@param  mixed $value
@return CollectionInterface
Put an item in the collection by key .