PropertiesCustomRatesPullCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 26
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 17 3
1
<?php
2
3
namespace IproSync\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use IproSync\Jobs\Properties\PropertyCustomRatesPull;
7
use IproSync\Models\Property;
8
9
class PropertiesCustomRatesPullCommand extends Command
10
{
11
    protected $signature = 'iprosoftware-sync:properties-custom-rates:pull
12
     {--id= : Pull property custom rates by ipro id.}
13
     {--queue= : Queue to dispatch job.}
14
    ';
15
16
    protected $description = 'Pull ipro properties custom rates';
17
18
    public function handle(): int
19
    {
20
        if ($id = $this->option('id')) {
21
            PropertyCustomRatesPull::dispatch($id)
22
                ->onQueue($this->option('queue'));
23
        } else {
24
            Property::query()
25
                    ->chunk(100, function ($properties) {
26
                        /** @var Property $property */
27
                        foreach ($properties as $property) {
28
                            PropertyCustomRatesPull::dispatch($property->getKey())
29
                                ->onQueue($this->option('queue'));
30
                        }
31
                    });
32
        }
33
34
        return 0;
35
    }
36
}
37