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.

JsonDriver   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 87.5%

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 6
c 3
b 0
f 3
lcom 1
cbo 1
dl 0
loc 34
ccs 14
cts 16
cp 0.875
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A formatData() 0 3 1
A getLastVersion() 0 10 3
A getAllVersions() 0 3 1
1
<?php
2
3
namespace ChangelogParser\Driver;
4
5
class JsonDriver extends Driver {
6 5
    public function __construct() {
7 5
        parent::__construct();
8 5
        $this->storagePath = __DIR__ . '/../../data/changelog.json';
9 5
    }
10
    
11
    /**
12
     * {@inheritdoc}
13
     */
14 3
    public final function formatData($data) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, final should precede the visibility keyword.
Loading history...
15 3
        return json_encode($data);
16
    }
17
    
18
    /**
19
     * {@inheritdoc}
20
     */
21 2
    public final function getLastVersion() {
0 ignored issues
show
Coding Style introduced by
As per PSR2, final should precede the visibility keyword.
Loading history...
22 2
        $data = json_decode($this->getAllVersions(), true);
23
        
24 2
        foreach($data as $version => $changelog) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FOREACH keyword; 0 found
Loading history...
25 2
            if($version === 'unreleased') {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
26 2
                continue;
27
            }
28 2
            return json_encode([$version => $changelog]);
29
        }
30
    }
31
    
32
    /**
33
     * {@inheritdoc}
34
     */
35 4
    public final function getAllVersions() {
0 ignored issues
show
Coding Style introduced by
As per PSR2, final should precede the visibility keyword.
Loading history...
36 4
        return file_get_contents($this->storagePath);
37
    }
38
}