WithSize   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 2
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
 * @mixin \Illuminate\Support\Collection
13
 *
14
 * @return \Illuminate\Support\Collection
15
 */
16
class WithSize
17
{
18
    public function __invoke()
19
    {
20
        return function (int $size): Collection {
21
            if ($size < 1) {
22
                return new Collection();
23
            }
24
25
            return new Collection(range(1, $size));
26
        };
27
    }
28
}
29