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

JigsawGenerateRobotsTxtFileAfterBuild   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
eloc 7
dl 0
loc 12
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 1
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