| 1 | <?php |
||
| 12 | class Fibonacci extends Combinatorics implements \Iterator, \Countable |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * The maximum limit. |
||
| 16 | * |
||
| 17 | * @var int |
||
| 18 | */ |
||
| 19 | protected $max; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * The previous element. |
||
| 23 | * |
||
| 24 | * @var int |
||
| 25 | */ |
||
| 26 | private $previous = 1; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * The current element. |
||
| 30 | * |
||
| 31 | * @var int |
||
| 32 | */ |
||
| 33 | private $current = 0; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * The current key. |
||
| 37 | * |
||
| 38 | * @var int |
||
| 39 | */ |
||
| 40 | private $key = 0; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Fibonacci constructor. |
||
| 44 | */ |
||
| 45 | public function __construct() |
||
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritdoc} |
||
| 52 | */ |
||
| 53 | public function current() |
||
| 57 | |||
| 58 | /** |
||
| 59 | * {@inheritdoc} |
||
| 60 | */ |
||
| 61 | public function key() |
||
| 65 | |||
| 66 | /** |
||
| 67 | * {@inheritdoc} |
||
| 68 | */ |
||
| 69 | public function next() |
||
| 74 | |||
| 75 | /** |
||
| 76 | * {@inheritdoc} |
||
| 77 | */ |
||
| 78 | public function rewind() |
||
| 84 | |||
| 85 | /** |
||
| 86 | * {@inheritdoc} |
||
| 87 | */ |
||
| 88 | public function valid() |
||
| 92 | |||
| 93 | /** |
||
| 94 | * {@inheritdoc} |
||
| 95 | */ |
||
| 96 | public function count() |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Convert the iterator into an array. |
||
| 103 | * |
||
| 104 | * @return array |
||
| 105 | * The elements. |
||
| 106 | */ |
||
| 107 | public function toArray() |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Set the maximum limit. |
||
| 120 | * |
||
| 121 | * @param int $max |
||
| 122 | * The limit. |
||
| 123 | */ |
||
| 124 | public function setMaxLimit($max) |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Get the maximum limit. |
||
| 131 | * |
||
| 132 | * @return int |
||
| 133 | * The limit. |
||
| 134 | */ |
||
| 135 | public function getMaxLimit() |
||
| 139 | } |
||
| 140 |