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.

AnalysisResult::countFiles()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Inspector\Analysis\Result;
4
5
/**
6
 * @author Kabir Baidhya
7
 */
8
class AnalysisResult
9
{
10
11
    const MAX_CODE_RATING = 10;
12
13
    const MAX_CODE_RATING_FILE = 4;
14
15
    /**
16
     * @var AnalyzedFile[]
17
     */
18
    protected $analyzedFiles;
19
20
    /**
21
     * @param AnalyzedFile[] $analyzedFiles
22
     */
23
    public function __construct(array $analyzedFiles)
24
    {
25
        $this->analyzedFiles = $analyzedFiles;
26
    }
27
28
    public function getCodeRating()
29
    {
30
        $totalRating = 0;
31
        foreach ($this->analyzedFiles as $file) {
32
            $totalRating += $file->getQuality();
33
        }
34
35
        $totalFiles = $this->countFiles();
36
37
        $rating = number_format(($totalFiles === 0) ? 0 : (($totalRating / $totalFiles) / self::MAX_CODE_RATING_FILE) * self::MAX_CODE_RATING,
38
            2);
39
40
        return $rating;
41
    }
42
43
    public function countFiles()
44
    {
45
        return count($this->analyzedFiles);
46
    }
47
48
    public function getRatingText()
49
    {
50
        $ratingText = [
51
            0 => 'No Rating',
52
            1 => 'Very Bad',
53
            2 => 'Very Bad',
54
            3 => 'Very Good',
55
            4 => 'Bad',
56
            5 => 'Moderate',
57
            6 => 'Not Bad',
58
            8 => 'Good',
59
            7 => 'Very Good',
60
            9 => 'Very Good',
61
            10 => 'Awesome',
62
        ];
63
        $rating = (int)floor($this->getCodeRating());
64
65
        return $ratingText[$rating];
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getRatingDescription()
72
    {
73
        return sprintf('%s out of 10 - %s', $this->getCodeRating(), $this->getRatingText());
74
    }
75
76
    /**
77
     * @return int
78
     */
79
    public function countIssues()
80
    {
81
        $issueCount = 0;
82
        foreach ($this->getFiles() as $file) {
83
            $issueCount += $file->getIssueCount();
84
        }
85
86
        return $issueCount;
87
    }
88
89
    /**
90
     * @return array|AnalyzedFile[]
91
     */
92
    public function getFiles()
93
    {
94
        return $this->analyzedFiles;
95
    }
96
97
}
98