public static function fromListExtractor($list, callable $extractor, callable $creator = null)
    {
        Assertion::isTraversable($list);

        $references = [];

        if (null === $creator) {
            $creator = function ($data) {
                return $data;
            };
        }

        foreach ($list as $index => $item) {
            $data = $extractor($item);

            if (null === $data) {
                continue;
            }

            $reference = $creator($data);

            if ($reference instanceof RecordReferenceInterface) {
                $references[$index] = $reference;
            }
        }

        return new self($references);
    }
public static function fromListExtractor($list, callable $extractor, callable $creator = null)
    {
        Assertion::isTraversable($list);

        $references = [];

        if (null === $creator) {
            $creator = function ($data) {
                return $data;
            };
        }

        foreach ($list as $index => $item) {
            $data = $extractor($item);

            if (null === $data) {
                continue;
            }

            $reference = $creator($data);

            if ($reference instanceof RecordReferenceInterface) {
                $references[$index] = $reference;
            }
        }

        return new self($references);
    }
public static function fromListExtractor ( $ list , callable $ extractor , callable $ creator = null ) { Assertion :: isTraversable ( $ list ) ; $ references = [ ] ; if ( null === $ creator ) { $ creator = function ( $ data ) { return $ data ; } ; } foreach ( $ list as $ index => $ item ) { $ data = $ extractor ( $ item ) ; if ( null === $ data ) { continue ; } $ reference = $ creator ( $ data ) ; if ( $ reference instanceof RecordReferenceInterface ) { $ references [ $ index ] = $ reference ; } } return new self ( $ references ) ; }
Append all RecordReferences extracted via call to extractor on each element

@param array|\Traversable $list List of elements to process
@param callable $extractor Extracts data from each element or return null if unavailable
@param callable $creator Creates Reference from extracted data. no-op when null
@return RecordReferenceCollection
Append all RecordReferences extracted via call to extractor on each element