Passed
Push — main ( 545ade...3cfdef )
by Andrey
79:39 queued 77:29
created

Validator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 28
ccs 11
cts 11
cp 1
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A package() 0 9 3
A locale() 0 6 2
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Support;
4
5
use Helldar\LaravelLangPublisher\Concerns\Logger;
6
use Helldar\LaravelLangPublisher\Concerns\Pathable;
7
use Helldar\LaravelLangPublisher\Constants\Locales as LocalesList;
8
use Helldar\LaravelLangPublisher\Exceptions\PackageDoesntExistsException;
9
use Helldar\LaravelLangPublisher\Exceptions\SourceLocaleDoesntExistsException;
10
use Helldar\LaravelLangPublisher\Facades\Locales as LocalesFacade;
11
use Helldar\Support\Facades\Helpers\Filesystem\Directory;
12
13
class Validator
14
{
15
    use Logger;
0 ignored issues
show
Bug introduced by
The trait Helldar\LaravelLangPublisher\Concerns\Logger requires the property $output which is not provided by Helldar\LaravelLangPublisher\Support\Validator.
Loading history...
16
    use Pathable;
17
18
    /**
19
     * Checking for localization existence.
20
     *
21
     * @param  string  $locale
22
     */
23 13
    public function locale(string $locale): void
24
    {
25 13
        $this->log('Checking for localization existence: ' . $locale);
26
27 13
        if (! LocalesFacade::isAvailable($locale)) {
28 1
            throw new SourceLocaleDoesntExistsException($locale);
29
        }
30 12
    }
31
32 14
    public function package(string $package): void
33
    {
34 14
        $this->log('Checking for package existence: ' . $package);
35
36 14
        $source  = $this->pathSource($package, LocalesList::ENGLISH);
37 14
        $locales = $this->pathLocales($package);
38
39 14
        if (Directory::doesntExist($source) || Directory::doesntExist($locales)) {
40 2
            throw new PackageDoesntExistsException($package);
41
        }
42 12
    }
43
}
44