Passed
Push — master ( c97482...68f9e3 )
by Andrey
07:00 queued 04:30
created

BasePath::real()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Support\Path;
4
5
use Helldar\LaravelLangPublisher\Contracts\Pathable;
6
7
abstract class BasePath implements Pathable
8
{
9
    protected $is_json = false;
10
11 102
    protected function real(string $path): string
12
    {
13 102
        return realpath($path);
14
    }
15
16 102
    protected function clean(string $path = null): ?string
17
    {
18 102
        return $path
19 102
            ? static::DIVIDER . ltrim($path, ' \\/')
20 102
            : $path;
21
    }
22
23 102
    protected function getPathForEnglish(string $locale): string
24
    {
25 102
        if ($this->is_json) {
26 54
            return $locale === 'en'
27 54
                ? '/script/en/en.json'
28 54
                : '/json/' . $locale . '.json';
29
        }
30
31 48
        return $locale === 'en'
32 48
            ? '/script/en'
33 48
            : '/src/' . $locale;
34
    }
35
}
36