GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 5ee131...02dba5 )
by Axel
03:06
created

ChangelogManager::getAllVersions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2.0054

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
dl 0
loc 11
ccs 8
cts 9
cp 0.8889
rs 9.4285
cc 2
eloc 9
nc 2
nop 2
crap 2.0054
1
<?php
2
3
namespace ChangelogParser\Manager;
4
5
class ChangelogManager {
6
    /** @var \ChangelogParser\Driver\Driver **/
7
    protected $driver;
8
    /** @var \ChangelogParser\Manager\CacheManager **/
9
    protected $cacheManager;
10
    /** @var string **/
11
    protected $storagePath;
12
    
13 2
    public function __construct() {
14 2
        $this->cacheManager = new CacheManager();
15 2
    }
16
    
17
    /**
18
     * @param string $storagePath
19
     * @return \ChangelogParser\Driver\Driver
20
     */
21 2
    public function setStoragePath($storagePath) {
22 2
        $this->storagePath = $storagePath;
23
        
24 2
        return $this;
25
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function getStoragePath() {
31
        return $this->storagePath;
32
    }
33
    
34
    /**
35
     * @param string $filepath
36
     * @param string $format
37
     * @return mixed
38
     */
39 1
    public function getLastVersion($filepath, $format = 'json') {
40 1
        $cacheFile = "last-version-$format";
41 1
        if(($cache = $this->cacheManager->getCache($filepath, $cacheFile)) !== false) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
42
            return $cache;
43
        }
44 1
        $this->initializeDriver($format);
45 1
        $this->driver->convert($filepath);
46 1
        $content = $this->driver->getLastVersion();
0 ignored issues
show
Bug introduced by
The method getLastVersion() cannot be called from this context as it is declared protected in class ChangelogParser\Driver\Driver.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
47 1
        $this->cacheManager->generateCache($filepath, $cacheFile, $content);
48 1
        return $content;
49
    }
50
    
51
    /**
52
     * @param string $filepath
53
     * @param string $format
54
     * @return mixed
55
     */
56 1
    public function getAllVersions($filepath, $format = 'json') {
57 1
        $cacheFile = "all-versions-$format";
58 1
        if(($cache = $this->cacheManager->getCache($filepath, $cacheFile)) !== false) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
59
            return $cache;
60
        }
61 1
        $this->initializeDriver($format);
62 1
        $this->driver->convert($filepath);
63 1
        $content = $this->driver->getAllVersions();
0 ignored issues
show
Bug introduced by
The method getAllVersions() cannot be called from this context as it is declared protected in class ChangelogParser\Driver\Driver.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
64 1
        $this->cacheManager->generateCache($filepath, $cacheFile, $content);
65 1
        return $content;
66
    }
67
    
68
    /**
69
     * @param string $format
70
     * @throws \InvalidArgumentException
71
     */
72 2
    public function initializeDriver($format) {
73 2
        $driverClass = 'ChangelogParser\\Driver\\' . ucfirst($format) . 'Driver';
74
        
75 2
        if(!class_exists($driverClass)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
76
            throw new \InvalidArgumentException('The requested format is not supported');
77
        }
78
        
79 2
        $this->driver = new $driverClass();
80 2
        if($this->storagePath !== null) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
81 2
            $this->driver->setStoragePath($this->storagePath);
82 2
        }
83 2
    }
84
    
85
    /**
86
     * @return \ChangelogParser\Manager\CacheManager
87
     */
88
    public function getCacheManager() {
89
        return $this->cacheManager;
90
    }
91
}