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 | */ |
||
28 | 106 | public function __construct($input) |
|
43 | |||
44 | /** |
||
45 | * Static alias of normal constructor. |
||
46 | * |
||
47 | * @param callable|array|Traversable $input |
||
48 | * @return Collection |
||
49 | */ |
||
50 | 8 | public static function from($input) |
|
54 | |||
55 | /** |
||
56 | * Returns lazy collection of values, where first value is $input and all subsequent values are computed by applying |
||
57 | * $function to the last value in the collection. By default this produces an infinite collection. However you can |
||
58 | * end the collection by throwing a NoMoreItems exception. |
||
59 | * |
||
60 | * @param mixed $input |
||
61 | * @param callable $function |
||
62 | * @return Collection |
||
63 | */ |
||
64 | 2 | public static function iterate($input, callable $function) |
|
68 | |||
69 | /** |
||
70 | * Returns a lazy collection of $value repeated $times times. If $times is not provided the collection is infinite. |
||
71 | * |
||
72 | * @param mixed $value |
||
73 | * @param int $times |
||
74 | * @return Collection |
||
75 | */ |
||
76 | 3 | public static function repeat($value, $times = -1) |
|
80 | |||
81 | /** |
||
82 | * Returns a lazy collection of numbers starting at $start, incremented by $step until $end is reached. |
||
83 | * |
||
84 | * @param int $start |
||
85 | * @param int|null $end |
||
86 | * @param int $step |
||
87 | * @return Collection |
||
88 | */ |
||
89 | 2 | public static function range($start = 0, $end = null, $step = 1) |
|
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | * @throws InvalidReturnValue |
||
97 | */ |
||
98 | 103 | public function getIterator() |
|
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | 1 | public function serialize() |
|
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | 1 | public function unserialize($serialized) |
|
141 | } |
||
142 |