Completed
Push — master ( 6dd3a0...ec39b9 )
by Níckolas Daniel
05:32
created

JigsawGenerateRobotsTxtFileAfterBuild::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace PODEntender\Infrastructure\Application\StaticSite\FileProcessing;
4
5
use PODEntender\Infrastructure\Application\StaticSite\JigsawEventHandler;
6
use TightenCo\Jigsaw\Jigsaw;
7
use PODEntender\Infrastructure\Domain\Factory\JigsawRobotsTxtFactory;
8
use PODEntender\Application\Service\FileProcessing\GenerateRobotsTxtFile;
9
10
class JigsawGenerateRobotsTxtFileAfterBuild implements JigsawEventHandler
11
{
12
    public function handle(Jigsaw $jigsaw): void
13
    {
14
        $robots = $jigsaw->app->make(JigsawRobotsTxtFactory::class);
15
        $fileGenerator = $jigsaw->app->make(GenerateRobotsTxtFile::class);
16
        $outputFile = $fileGenerator->execute(
17
            $robots->newRobotsTxtFromConfiguration($jigsaw->getConfig('robots.RobotsTxt')),
18
            $jigsaw->getDestinationPath() . '/robots.txt'
19
        );
20
21
        file_put_contents($outputFile->path(), $outputFile->content());
22
    }
23
}
24