Test Failed
Push — master ( e2a2a8...073eac )
by Tom
06:01 queued 12s
created

FeedFactory::makeFromSheetCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Astrotomic\Stancy\Factories;
4
5
use Astrotomic\Stancy\Contracts\FeedFactory as FeedFactoryContract;
6
use Astrotomic\Stancy\Contracts\Page as PageContract;
7
use Astrotomic\Stancy\Contracts\PageFactory as PageFactoryContract;
8
use Illuminate\Support\Collection;
9
use Spatie\Sheets\Facades\Sheets;
10
use Spatie\Sheets\Repository as SheetRepository;
11
use Spatie\Sheets\Sheet;
12
13
class FeedFactory implements FeedFactoryContract
14
{
15
    /** @var PageFactoryContract */
16
    protected $pageFactory;
17
18 2
    public function __construct(PageFactoryContract $pageFactory)
19
    {
20 2
        $this->pageFactory = $pageFactory;
21 2
    }
22
23
    public function makeFromSheetCollectionName(string $name): Collection
24
    {
25
        $collection = Sheets::collection($name);
26
27
        return $this->makeFromSheetCollection($collection);
28
    }
29
30
    protected function makeFromSheetCollection(SheetRepository $collection): Collection
31
    {
32
        return $collection->all()->map(function (Sheet $sheet): PageContract {
33
            return $this->pageFactory->makeFromSheet($sheet);
34
        });
35
    }
36
}
37