Completed
Pull Request — master (#98)
by Hiraku
07:53 queued 05:39
created

ConfigFacade::getUserAgent()   B

Complexity

Conditions 4
Paths 3

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4.0092

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 22
ccs 11
cts 12
cp 0.9167
rs 8.9197
cc 4
eloc 14
nc 3
nop 0
crap 4.0092
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
        /** @codeCoverageIgnoreStart */
16 1
        if (defined('HHVM_VERSION')) {
17
            $phpVersion = 'HHVM ' . HHVM_VERSION;
18
        } else {
19 1
            $phpVersion = 'PHP ' . PHP_VERSION;
20
        }
21
        /** @codeCoverageIgnoreEnd */
22
23 1
        return $ua = sprintf(
24 1
            'Composer/%s (%s; %s; %s)',
25 1
            Composer::VERSION === '@package_version@' ? 'source' : Composer::VERSION,
26 1
            php_uname('s'),
27 1
            php_uname('r'),
28
            $phpVersion
29
        );
30
    }
31
32 1
    public function __debugInfo()
33
    {
34
        return array(
35 1
            'user-agent' => $this->getUserAgent(),
36
        );
37
    }
38
}
39