Passed
Push — master ( ddfabf...6c2ee4 )
by Tom
03:14 queued 10s
created

ConvertsSheetToPage::sheetsToPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
c 1
b 0
f 1
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Astrotomic\Stancy\Traits;
4
5
use Astrotomic\Stancy\Contracts\Page as PageContract;
6
use Astrotomic\Stancy\Contracts\PageFactory as PageFactoryContract;
7
use Spatie\Sheets\Sheet;
8
9
/**
10
 * @internal
11
 */
12
trait ConvertsSheetToPage
13
{
14
    /** @var PageFactoryContract */
15
    protected $pageFactory;
16
17
    /**
18
     * @param Sheet[] $sheets
19
     *
20
     * @return PageContract[]
21
     */
22 2
    protected function sheetsToPages(array $sheets): array
23
    {
24
        return array_map(function (Sheet $sheet): PageContract {
25 2
            return $this->sheetToPage($sheet);
26 2
        }, $sheets);
27
    }
28
29 5
    protected function sheetToPage(Sheet $sheet): PageContract
30
    {
31 5
        return $this->pageFactory->makeFromSheet($sheet);
32
    }
33
}
34