keys()

Keys operator iterates over given stream of iterables and yields only list of keys.

class RunOpenCode\Component\Dataset\Operator\Keys
__construct(iterable<TKey, TValue> $source)
Parameters:
  • $source – iterable<TKey, TValue> Stream of items to iterate over.

getIterator()
Returns:

\Traversable<int, TKey> Stream of keys.

Use cases

  • Use this operator to get only keys of a dataset.

Example

1<?php
2
3use RunOpenCode\Component\Dataset\Stream;
4
5new Stream($dataset)
6    ->keys(); // yields only keys of the dataset.