Completed
Pull Request — master (#101)
by Hiraku
05:27
created

ConfigFacade::getUserAgent()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0175

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 15
rs 9.4285
ccs 7
cts 8
cp 0.875
cc 3
eloc 10
nc 2
nop 0
crap 3.0175
1
<?php
2
namespace Hirak\Prestissimo;
3
4
use Composer\Composer;
5
use Composer\Config;
6
7
class ConfigFacade
8
{
9 3
    public static function getUserAgent()
10
    {
11 3
        static $ua;
12 3
        if ($ua) {
13 2
            return $ua;
14
        }
15
16 1
        return $ua = sprintf(
17
            'Composer/%s (%s; %s; %s)',
18
            Composer::VERSION === '@package_version@' ? 'source' : Composer::VERSION,
19 1
            php_uname('s'),
20
            php_uname('r'),
21
            self::getPHPVersion()
22
        );
23 1
    }
24 1
25 1
    /**
26 1
     * @codeCoverageIgnore
27 1
     */
28
    private static function getPHPVersion()
29
    {
30
        if (defined('HHVM_VERSION')) {
31
            return 'HHVM ' . HHVM_VERSION;
32 1
        }
33
        return 'PHP ' . PHP_VERSION;
34
    }
35
}
36