GenerateSitemap   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A execute() 0 4 1
A configure() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chinstrap\Core\Console\Commands;
6
7
use Chinstrap\Core\Contracts\Generators\Sitemap;
8
use League\Flysystem\FilesystemInterface;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
final class GenerateSitemap extends Command
14
{
15
    protected Sitemap $sitemap;
16
17
    protected FilesystemInterface $manager;
18
19
    public function __construct(Sitemap $sitemap, FilesystemInterface $manager)
20
    {
21
        parent::__construct();
22
        $this->sitemap = $sitemap;
23
        $this->manager = $manager;
24
    }
25
26
    protected function configure(): void
27
    {
28
        $this->setName('sitemap:generate')
29
                ->setDescription('Generates the sitemap')
30
                ->setHelp('This command will generate the sitemap');
31
    }
32
33
    protected function execute(InputInterface $input, OutputInterface $output): int
34
    {
35
        $this->manager->put('assets://sitemap.xml', $this->sitemap->__invoke());
36
        return 1;
37
    }
38
}
39