Completed
Pull Request — master (#18)
by Bill
02:11
created

Result::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
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 string
16
     */
17
    private $commits;
18
19
    /**
20
     * The complexity property.
21
     * @var string
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 string
48
     */
49
    public function getCommits(): string
50
    {
51
        return $this->commits;
52
    }
53
54
    /**
55
     * Get the file property.
56
     * @return string
57
     */
58
    public function getComplexity(): string
59
    {
60
        return $this->complexity;
61
    }
62
63
    /**
64
     * Calculate the score.
65
     * @return string
66
     */
67
    public function getScore(): string
68
    {
69
        return $this->getCommits() + $this->getComplexity();
70
    }
71
72
    /**
73
     * Output results to an array.
74
     * @return string
75
     */
76
    public function toArray(): string
77
    {
78
        return [
79
            $this->getFile(),
80
            $this->getCommits(),
81
            $this->getComplexity(),
82
            $this->getScore(),
83
        ];
84
    }
85
}
86