Completed
Push — master ( baf737...1f6f50 )
by Jeremy
08:14
created

GenerateSitemap   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 11 2
1
<?php
2
3
namespace App\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Spatie\Sitemap\SitemapGenerator;
7
8
class GenerateSitemap extends Command
9
{
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'sitemap:generate {limit=-1}';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Generate the sitemap.';
23
24
    /**
25
     * Create a new command instance.
26
     *
27
     * @return void
28
     */
29
    public function __construct()
30
    {
31
        parent::__construct();
32
    }
33
34
    /**
35
     * Execute the console command.
36
     *
37
     * @return mixed
38
     */
39
    public function handle()
40
    {
41
        $limit = config('blog.services.siteMapLimit');
42
43
        if ($this->argument('limit')) {
44
            $limit = $this->argument('limit');
45
        }
46
47
        SitemapGenerator::create(config('app.url'))
48
            ->setMaximumCrawlCount($limit)
49
            ->writeToFile(public_path('sitemap.xml'));
50
    }
51
}
52