menu_path()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 11
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
use Illuminate\Container\Container;
4
use Illuminate\Contracts\Config\Repository as ConfigRepository;
5
6
if (! function_exists('menu_path')) {
7
    /**
8
     * Get the path to the menus directory.
9
     */
10
    function menu_path(string $path = ''): string
11
    {
12 49
        $app = Container::getInstance();
13
14 49
        $config = $app->make(ConfigRepository::class);
15
16 49
        $menusDir = $config->get('ussd.menu-path');
17
18 49
        $path = $path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path;
19
20 49
        return $app->basePath($menusDir.$path);
0 ignored issues
show
introduced by
The method basePath() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        return $app->/** @scrutinizer ignore-call */ basePath($menusDir.$path);
Loading history...
21
    }
22
}
23