Passed
Branch feature/first-release (57b0a8)
by Andrea Marco
13:40
created

Macro::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Cerbero\LazyJsonPages;
4
5
use Illuminate\Support\LazyCollection;
6
7
/**
8
 * The lazy collection macro.
9
 *
10
 */
11
class Macro
12
{
13
    /**
14
     * Load paginated items of the given JSON source in a lazy collection
15
     *
16
     * @param \Psr\Http\Message\RequestInterface|\Illuminate\Http\Client\Response $source
17
     * @param string $path
18
     * @param callable|array|string|int $config
19
     * @return LazyCollection
20
     */
21
    public function __invoke($source, string $path, $config): LazyCollection
22
    {
23
        return new LazyCollection(function () use ($source, $path, $config) {
24
            yield from new Source($source, $path, $config);
25
        });
26
    }
27
}
28