Completed
Push — master ( 9e1ab8...e0f7b9 )
by Bill
04:14 queued 02:03
created

Result::getCommits()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
3
namespace Churn\Results;
4
5
class Result
6
{
7
    /**
8
     * The file property.
9
     * @var string
10
     */
11
    private $file;
12
13
    /**
14
     * The commits property.
15
     * @var integer
16
     */
17
    private $commits;
18
19
    /**
20
     * The complexity property.
21
     * @var integer
22
     */
23
    private $complexity;
24
25
    /**
26
     * Class constructor.
27
     * @param array $data Data to store in the object.
28
     */
29
    public function __construct(array $data)
30
    {
31
        $this->file       = $data['file'];
32
        $this->commits    = $data['commits'];
33
        $this->complexity = $data['complexity'];
34
    }
35
36
    /**
37
     * Get the file property.
38
     * @return string
39
     */
40
    public function getFile(): string
41
    {
42
        return $this->file;
43
    }
44
45
    /**
46
     * Get the file property.
47
     * @return integer
48
     */
49
    public function getCommits(): int
50
    {
51
        return $this->commits;
52
    }
53
54
    /**
55
     * Get the file property.
56
     * @return integer
57
     */
58
    public function getComplexity(): int
59
    {
60
        return $this->complexity;
61
    }
62
63
    /**
64
     * Calculate the score.
65
     * @return integer
66
     */
67
    public function getScore(): int
68
    {
69
        return $this->getCommits() + $this->getComplexity();
70
    }
71
72
    /**
73
     * Output results to an array.
74
     * @return array
75
     */
76
    public function toArray(): array
77
    {
78
        return [
79
            $this->getFile(),
80
            $this->getCommits(),
81
            $this->getComplexity(),
82
            $this->getScore(),
83
        ];
84
    }
85
}
86