Passed
Pull Request — main (#84)
by Andrey
196:26 queued 181:26
created

Reset::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Services\Processors;
4
5
use Helldar\LaravelLangPublisher\Concerns\Keyable;
6
use Helldar\LaravelLangPublisher\Concerns\Reservation;
7
use Helldar\LaravelLangPublisher\Constants\Status;
8
9
final class Reset extends Processor
10
{
11
    use Keyable;
12
    use Reservation;
13
14
    public function run(): string
15
    {
16
        $source = $this->load($this->source_path);
17
        $target = $this->load($this->target_path);
18
19
        $result = $this->compare($source, $target);
20
21
        $this->store($this->target_path, $result);
22
23
        return Status::RESET;
24
    }
25
26
    protected function compare(array $source, array $target): array
27
    {
28
        $target = $this->full ? [] : $this->only($target);
29
30
        return parent::compare($source, $target);
31
    }
32
33
    protected function only(array $array): array
34
    {
35
        return $this->reserved($array, $this->key($this->target_path));
36
    }
37
}
38