Passed
Push — master ( 342193...f80fe6 )
by Andrea Marco
03:14 queued 11s
created

OutOfAttemptsException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 9
c 1
b 0
f 0
dl 0
loc 36
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
1
<?php
2
3
namespace Cerbero\LazyJsonPages\Exceptions;
4
5
use Cerbero\LazyJsonPages\Outcome;
6
use Illuminate\Support\LazyCollection;
7
use Throwable;
8
9
/**
10
 * The out of attempts exception.
11
 *
12
 */
13
class OutOfAttemptsException extends LazyJsonPagesException
14
{
15
    /**
16
     * The original exception.
17
     *
18
     * @var Throwable
19
     */
20
    public $original;
21
22
    /**
23
     * The pages that caused the failure.
24
     *
25
     * @var array
26
     */
27
    public $failedPages;
28
29
    /**
30
     * The paginated items loaded before the failure.
31
     *
32
     * @var LazyCollection
33
     */
34
    public $items;
35
36
    /**
37
     * Instantiate the class.
38
     *
39
     * @param Throwable $original
40
     * @param Outcome $outcome
41
     */
42 2
    public function __construct(Throwable $original, Outcome $outcome)
43
    {
44 2
        $this->message = $original->getMessage();
45 2
        $this->original = $original;
46 2
        $this->failedPages = $outcome->pullFailedPages();
47 2
        $this->items = new LazyCollection(function () use ($outcome) {
48 2
            yield from $outcome->pullItems();
49 2
        });
50 2
    }
51
}
52