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

FileDownloaderDummy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 92.31%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
c 1
b 1
f 0
lcom 0
cbo 1
dl 0
loc 23
ccs 12
cts 13
cp 0.9231
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCacheKeyCompat() 0 15 3
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