1 | <?php |
||
11 | class Collection implements IteratorAggregate, \Serializable |
||
12 | { |
||
13 | use CollectionTrait; |
||
14 | |||
15 | /** |
||
16 | * @var Traversable |
||
17 | */ |
||
18 | protected $input; |
||
19 | |||
20 | /** |
||
21 | * @var callable |
||
22 | */ |
||
23 | private $inputFactory; |
||
24 | |||
25 | /** |
||
26 | * @param callable|array|Traversable $input If callable is passed, it must return an array|Traversable. |
||
27 | 102 | */ |
|
28 | public function __construct($input) |
||
47 | 8 | ||
48 | /** |
||
49 | 8 | * Static alias of normal constructor. |
|
50 | * |
||
51 | * @param callable|array|Traversable $input |
||
52 | * @return Collection |
||
53 | */ |
||
54 | public static function from($input) |
||
58 | |||
59 | /** |
||
60 | * Returns lazy collection of values, where first value is $input and all subsequent values are computed by applying |
||
61 | 2 | * $function to the last value in the collection. By default this produces an infinite collection. However you can |
|
62 | * end the collection by throwing a NoMoreItems exception. |
||
63 | 2 | * |
|
64 | * @param mixed $input |
||
65 | * @param callable $function |
||
66 | * @return Collection |
||
67 | */ |
||
68 | public static function iterate($input, callable $function) |
||
72 | |||
73 | 3 | /** |
|
74 | * Returns a lazy collection of $value repeated $times times. If $times is not provided the collection is infinite. |
||
75 | 3 | * |
|
76 | * @param mixed $value |
||
77 | * @param int $times |
||
78 | * @return Collection |
||
79 | */ |
||
80 | public static function repeat($value, $times = -1) |
||
84 | |||
85 | /** |
||
86 | 2 | * Returns a lazy collection of numbers starting at $start, incremented by $step until $end is reached. |
|
87 | * |
||
88 | 2 | * @param int $start |
|
89 | * @param int|null $end |
||
90 | * @param int $step |
||
91 | * @return Collection |
||
92 | */ |
||
93 | public static function range($start = 0, $end = null, $step = 1) |
||
97 | 77 | ||
98 | 77 | /** |
|
99 | * {@inheritdoc} |
||
100 | 100 | * @throws InvalidReturnValue |
|
101 | */ |
||
102 | public function getIterator() |
||
120 | |||
121 | /** |
||
122 | * {@inheritdoc} |
||
123 | 1 | */ |
|
124 | public function serialize() |
||
137 | |||
138 | /** |
||
139 | * {@inheritdoc} |
||
140 | */ |
||
141 | public function unserialize($serialized) |
||
145 | } |
||
146 |