Passed
Pull Request — master (#23)
by Sergei
02:03
created

Info::frameworkPath()   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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ErrorHandler;
6
7
use Composer\InstalledVersions;
8
use OutOfBoundsException;
9
10
final class Info
11
{
12 1
    public static function frameworkVersion(): string
13
    {
14
        // For composer 1
15 1
        if (!class_exists(InstalledVersions::class)) {
16
            return 'unknown version';
17
        }
18
19
        try {
20 1
            return InstalledVersions::getVersion('yiisoft/yii-web') ?? 'unknown version';
21 1
        } catch (OutOfBoundsException $e) {
22 1
            return 'unknown version';
23
        }
24
    }
25
26 1
    public static function frameworkPath(): string
27
    {
28 1
        return dirname(__DIR__, 3) . '/yii-web';
29
    }
30
}
31