Completed
Pull Request — newinternal (#285)
by Simon
07:17 queued 04:17
created

Environment::getToolVersion()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca;
10
11
/**
12
 * Class providing information about the tool's runtime environment
13
 */
14
class Environment
15
{
16
    /**
17
     * @var string Cached copy of the tool version
18
     */
19
    private static $toolVersion = null;
20
21
    /**
22
     * Gets the tool version, using cached data if available.
23
     * @return string
24
     */
25
    public static function getToolVersion()
26
    {
27
        if (self::$toolVersion === null) {
28
            self::$toolVersion = exec("git describe --always --dirty");
29
        }
30
31
        return self::$toolVersion;
32
    }
33
}
34