GenerateCategoriesAfterCollections::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 6
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace PODEntender\Infrastructure\Application\StaticSite;
4
5
use TightenCo\Jigsaw\Jigsaw;
6
use TightenCo\Jigsaw\PageVariable;
7
8
class GenerateCategoriesAfterCollections implements JigsawEventHandler
9
{
10
    const COLLECTION_NAME_ALL = 'Todos';
11
12
    public function handle(Jigsaw $jigsaw): void
13
    {
14
        $episodes = $jigsaw->getCollection('episodes');
15
16
        $jigsaw->getSiteData()->put(self::COLLECTION_NAME_ALL, $episodes);
17
18
        $episodes
19
            ->groupBy('category')
20
            ->each(function (PageVariable $episodes, string $category) use ($jigsaw) {
21
                $jigsaw
22
                    ->getSiteData()
23
                    ->put($category, $episodes);
24
            });
25
    }
26
}
27