Completed
Pull Request — master (#80)
by Hiraku
02:32
created

FileDownloaderDummy::getCacheKeyCompat()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3.009

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 17
ccs 9
cts 10
cp 0.9
rs 9.4285
cc 3
eloc 10
nc 4
nop 2
crap 3.009
1
<?php
2
/*
3
 * @author Hiraku NAKANO
4
 * @license MIT https://github.com/hirak/prestissimo
5
 */
6
namespace Hirak\Prestissimo;
7
8
use Composer\Package;
9
10
/**
11
 * dirty hack for getCacheKey compatiblity
12
 */
13
class FileDownloaderDummy extends \Composer\Downloader\FileDownloader
14
{
15 1
    public function __construct()
16
    {
17
        // do nothing
18 1
    }
19
20 2
    public static function getCacheKeyCompat(Package\PackageInterface $p, $processedUrl)
21
    {
22 2
        static $rgetCacheKey, $my, $params;
23 2
        if (!$rgetCacheKey) {
24 1
            $rgetCacheKey = new \ReflectionMethod('Composer\Downloader\FileDownloader', 'getCacheKey');
25 1
            $rgetCacheKey->setAccessible(true);
26 1
            $my = new self;
27 1
            $params = count($rgetCacheKey->getParameters());
28 1
        }
29 2
        if ($params === 1) {
30
            return $rgetCacheKey->invoke($my, $p);
31
        }
32
33
        // @codeCoverageIgnoreStart
34
        return $rgetCacheKey->invoke($my, $p, $processedUrl);
35
        // @codeCoverageIgnoreEnd
36
    }
37
}
38