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.

ChangelogManager   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 81.08%

Importance

Changes 7
Bugs 0 Features 4
Metric Value
wmc 11
c 7
b 0
f 4
lcom 1
cbo 2
dl 0
loc 87
ccs 30
cts 37
cp 0.8108
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setStoragePath() 0 5 1
A getStoragePath() 0 3 1
A getLastVersion() 0 11 2
A getAllVersions() 0 11 2
A initializeDriver() 0 12 3
A getCacheManager() 0 3 1
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
}