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 function current; 21 use function key; 22 use function next; 23 use function reset; 24 25 /** 26 * DatabaseInfoIterator for inline listDatabases command results. 27 * 28 * This iterator may be used to wrap the array returned within the listDatabases 29 * command's single-document result. 30 * 31 * @internal 32 * @see \MongoDB\Client::listDatabases() 33 * @see https://mongodb.com/docs/manual/reference/command/listDatabases/ 34 */ 35 class DatabaseInfoLegacyIterator implements DatabaseInfoIterator 36 { 37 /** @var array */ 38 private $databases; 39 40 public function __construct(array $databases) 41 { 42 $this->databases = $databases; 43 } 44 45 /** 46 * Return the current element as a DatabaseInfo instance. 47 * 48 * @see DatabaseInfoIterator::current() 49 * @see https://php.net/iterator.current 50 */ 51 public function current(): DatabaseInfo 52 { 53 return new DatabaseInfo(current($this->databases)); 54 } 55 56 /** 57 * Return the key of the current element. 58 * 59 * @see https://php.net/iterator.key 60 */ 61 public function key(): int 62 { 63 return key($this->databases); 64 } 65 66 /** 67 * Move forward to next element. 68 * 69 * @see https://php.net/iterator.next 70 */ 71 public function next(): void 72 { 73 next($this->databases); 74 } 75 76 /** 77 * Rewind the Iterator to the first element. 78 * 79 * @see https://php.net/iterator.rewind 80 */ 81 public function rewind(): void 82 { 83 reset($this->databases); 84 } 85 86 /** 87 * Checks if current position is valid. 88 * 89 * @see https://php.net/iterator.valid 90 */ 91 public function valid(): bool 92 { 93 return key($this->databases) !== null; 94 } 95 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body