Completed
Push — master ( d683f2...a4cc9e )
by Tom
03:19
created

FeedFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A makeFromSheetCollectionName() 0 5 1
A __construct() 0 3 1
A makeFromSheetCollection() 0 5 1
1
<?php
2
3
namespace Astrotomic\Stancy\Factories;
4
5
use Astrotomic\Stancy\Contracts\FeedFactory as FeedFactoryContract;
6
use Astrotomic\Stancy\Contracts\PageFactory as PageFactoryContract;
7
use Spatie\Sheets\Facades\Sheets;
8
use Spatie\Sheets\Repository as SheetRepository;
9
use Spatie\Sheets\Sheet;
10
11
class FeedFactory implements FeedFactoryContract
12
{
13
    /** @var PageFactoryContract */
14
    protected $pageFactory;
15
16 3
    public function __construct(PageFactoryContract $pageFactory)
17
    {
18 3
        $this->pageFactory = $pageFactory;
19 3
    }
20
21 1
    public function makeFromSheetCollection(SheetRepository $collection): array
0 ignored issues
show
introduced by
Method \Astrotomic\Stancy\Factories\FeedFactory::makeFromSheetCollection() does not have @return annotation for its traversable return value.
Loading history...
22
    {
23
        return $collection->all()->map(function(Sheet $sheet) {
0 ignored issues
show
introduced by
You should change the following
<fg=red>- return $collection->all()->map(function(Sheet $sheet) {
</><fg=green>+ return $collection->all()->map(function (Sheet $sheet) {
</>
Loading history...
24 1
            return $this->pageFactory->makeFromSheet($sheet);
25 1
        })->all();
26
    }
27
28 1
    public function makeFromSheetCollectionName(string $name): array
0 ignored issues
show
introduced by
Method \Astrotomic\Stancy\Factories\FeedFactory::makeFromSheetCollectionName() does not have @return annotation for its traversable return value.
Loading history...
29
    {
30 1
        $collection = Sheets::collection($name);
31
32 1
        return $this->makeFromSheetCollection($collection);
33
    }
34
}
35