See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
1 <?php 2 /* 3 * Copyright 2015-present MongoDB, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * https://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 namespace MongoDB\Model; 19 20 use IteratorIterator; 21 use Traversable; 22 23 use function array_key_exists; 24 25 /** 26 * IndexInfoIterator for both listIndexes command and legacy query results. 27 * 28 * This common iterator may be used to wrap a Cursor returned by both the 29 * listIndexes command and, for legacy servers, queries on the "system.indexes" 30 * collection. 31 * 32 * @internal 33 * @see \MongoDB\Collection::listIndexes() 34 * @see https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst 35 * @see https://mongodb.com/docs/manual/reference/command/listIndexes/ 36 * @see https://mongodb.com/docs/manual/reference/system-collections/ 37 */ 38 class IndexInfoIteratorIterator extends IteratorIterator implements IndexInfoIterator 39 { 40 /** @var string|null $ns */ 41 private $ns; 42 43 public function __construct(Traversable $iterator, ?string $ns = null) 44 { 45 parent::__construct($iterator); 46 47 $this->ns = $ns; 48 } 49 50 /** 51 * Return the current element as an IndexInfo instance. 52 * 53 * @see IndexInfoIterator::current() 54 * @see https://php.net/iterator.current 55 */ 56 public function current(): IndexInfo 57 { 58 $info = parent::current(); 59 60 if (! array_key_exists('ns', $info) && $this->ns !== null) { 61 $info['ns'] = $this->ns; 62 } 63 64 return new IndexInfo($info); 65 } 66 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body