Passed
Pull Request — main (#96)
by Andrey
50:33 queued 35:34
created

Validator::package()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Support;
4
5
use Helldar\LaravelLangPublisher\Concerns\Logger;
6
use Helldar\LaravelLangPublisher\Exceptions\PackageDoesntExistsException;
7
use Helldar\LaravelLangPublisher\Exceptions\SourceLocaleDoesntExistsException;
8
use Helldar\LaravelLangPublisher\Facades\Config as ConfigFacade;
9
use Helldar\LaravelLangPublisher\Facades\Locales as LocalesFacade;
10
11
class Validator
12
{
13
    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...
14
15
    /**
16
     * Checking for localization existence.
17
     *
18
     * @param  string  $locale
19
     */
20
    public function locale(string $locale): void
21
    {
22
        $this->log('Checking for localization existence: ' . $locale);
23
24
        if (! LocalesFacade::isAvailable($locale)) {
25
            throw new SourceLocaleDoesntExistsException($locale);
26
        }
27
    }
28
29
    public function package(string $package): void
30
    {
31
        $this->log('Checking for package existence: ' . $package);
32
33
        if (! in_array($package, ConfigFacade::packages(), true)) {
34
            throw new PackageDoesntExistsException($package);
35
        }
36
    }
37
}
38