1 | <?php |
||
10 | class Collection implements IteratorAggregate, \Serializable |
||
11 | { |
||
12 | use CollectionTrait; |
||
13 | |||
14 | /** |
||
15 | * @var Traversable |
||
16 | */ |
||
17 | protected $input; |
||
18 | |||
19 | /** |
||
20 | * @var callable |
||
21 | */ |
||
22 | private $inputFactory; |
||
23 | |||
24 | /** |
||
25 | * @param callable|array|Traversable $input If callable is passed, it must return an array|Traversable. |
||
26 | */ |
||
27 | 101 | public function __construct($input) |
|
40 | |||
41 | /** |
||
42 | * Static alias of normal constructor. |
||
43 | * |
||
44 | * @param callable|array|Traversable $input |
||
45 | * @return Collection |
||
46 | */ |
||
47 | 8 | public static function from($input) |
|
51 | |||
52 | /** |
||
53 | * Returns lazy collection of values, where first value is $input and all subsequent values are computed by applying |
||
54 | * $function to the last value in the collection. By default this produces an infinite collection. However you can |
||
55 | * end the collection by throwing a NoMoreItems exception. |
||
56 | * |
||
57 | * @param mixed $input |
||
58 | * @param callable $function |
||
59 | * @return Collection |
||
60 | */ |
||
61 | 2 | public static function iterate($input, callable $function) |
|
65 | |||
66 | /** |
||
67 | * Returns a lazy collection of $value repeated $times times. If $times is not provided the collection is infinite. |
||
68 | * |
||
69 | * @param mixed $value |
||
70 | * @param int $times |
||
71 | * @return Collection |
||
72 | */ |
||
73 | 4 | public static function repeat($value, $times = -1) |
|
77 | |||
78 | /** |
||
79 | * Returns a lazy collection of numbers starting at $start, incremented by $step until $end is reached. |
||
80 | * |
||
81 | * @param int $start |
||
82 | * @param int|null $end |
||
83 | * @param int $step |
||
84 | * @return Collection |
||
85 | */ |
||
86 | 2 | public static function range($start = 0, $end = null, $step = 1) |
|
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | 99 | public function getIterator() |
|
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | 1 | public function serialize() |
|
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | 1 | public function unserialize($serialized) |
|
127 | } |
||
128 |