Completed
Pull Request — master (#51)
by Hiraku
02:26
created

FileDownloaderDummy::getCacheKeyCompat()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3.0067

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 15
ccs 10
cts 11
cp 0.9091
rs 9.4285
cc 3
eloc 10
nc 4
nop 2
crap 3.0067
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
// dirty hack for getCacheKey compatiblity
11
class FileDownloaderDummy extends \Composer\Downloader\FileDownloader
12
{
13 1
    public function __construct()
14
    {
15
        // do nothing
16 1
    }
17
18 2
    public static function getCacheKeyCompat(Package\PackageInterface $p, $processedUrl)
19
    {
20 2
        static $rgetCacheKey, $my, $params;
21 2
        if (!$rgetCacheKey) {
22 1
            $rgetCacheKey = new \ReflectionMethod('Composer\Downloader\FileDownloader', 'getCacheKey');
23 1
            $rgetCacheKey->setAccessible(true);
24 1
            $my = new self;
25 1
            $params = count($rgetCacheKey->getParameters());
26 1
        }
27 2
        if ($params === 1) {
28 2
            return $rgetCacheKey->invoke($my, $p);
29
        }
30
31
        return $rgetCacheKey->invoke($my, $p, $processedUrl);
32
    }
33
}
34