Completed
Push — master ( 3b5f38...c5ceed )
by Tomáš
04:59
created

VendorDirProvider::provide()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\PHP7_CodeSniffer\SniffFinder\Composer;
9
10
use Composer\Autoload\ClassLoader;
11
use ReflectionClass;
12
13
final class VendorDirProvider
14
{
15
    /**
16
     * @var string
17
     */
18
    private static $vendorDir;
19
20 6
    public static function provide() : string
21
    {
22 6
        if (self::$vendorDir) {
23 5
            return self::$vendorDir;
24
        }
25
26 1
        $classLoaderReflection = new ReflectionClass(ClassLoader::class);
27 1
        self::$vendorDir = dirname(dirname($classLoaderReflection->getFileName()));
28
29 1
        return self::$vendorDir;
30
    }
31
}
32