Completed
Pull Request — master (#162)
by
unknown
01:22
created

WithSize::__invoke()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 1
nop 0
1
<?php
2
3
namespace Spatie\CollectionMacros\Macros;
4
5
use Illuminate\Support\Collection;
6
7
/*
8
 * Create a new collection with the specified amount of items
9
 *
10
 * @param int $size
11
 *
12
 * @return \Illuminate\Support\Collection
13
 */
14
class WithSize
15
{
16
    public function __invoke()
17
    {
18
        return function (int $size): Collection {
19
            if ($size < 1) {
20
                return new Collection();
21
            }
22
23
            return new Collection(range(1, $size));
24
        };
25
    }
26
}
27