Passed
Pull Request — main (#84)
by Andrey
59:33 queued 44:34
created

Manage::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Services\Comparators;
4
5
use Helldar\LaravelLangPublisher\Concerns\Contains;
6
use Helldar\LaravelLangPublisher\Concerns\Logger;
7
use Helldar\LaravelLangPublisher\Contracts\Comparator as ComparatorContract;
8
use Helldar\LaravelLangPublisher\Facades\Path;
9
use Helldar\Support\Concerns\Makeable;
10
11
final class Manage
12
{
13
    use Contains;
14
    use Logger;
15
    use Makeable;
16
17
    protected $source;
18
19
    protected $target;
20
21
    protected $filename;
22
23
    public function source(array $array): self
24
    {
25
        $this->source = $array;
26
27
        return $this;
28
    }
29
30
    public function target(array $array): self
31
    {
32
        $this->target = $array;
33
34
        return $this;
35
    }
36
37
    public function filename(string $filename): self
38
    {
39
        $this->filename = Path::filename($filename);
40
41
        return $this;
42
    }
43
44
    public function find(): ComparatorContract
45
    {
46
        $this->log('Comparison object definition...');
47
48
        return $this->resolve()
49
            ->source($this->source)
50
            ->target($this->target);
51
    }
52
53
    protected function resolve(): ComparatorContract
54
    {
55
        $this->log('Comparison object resolve...');
56
57
        return $this->isValidation($this->filename) ? Validation::make() : Basic::make();
58
    }
59
}
60