Completed
Push — develop ( 9b1d71...66130e )
by Adam
03:07 queued 01:21
created

ToneScore   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 82
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A create() 0 8 1
A getScore() 0 4 1
A getId() 0 4 1
A getName() 0 4 1
1
<?php
2
3
namespace IBM\Watson\ToneAnalyzer\Model;
4
5
use IBM\Watson\Common\Model\CreateableFromArray;
6
7
/**
8
 * Class ToneScore
9
 */
10
class ToneScore implements CreateableFromArray
11
{
12
    /**
13
     * @var string
14
     */
15
    const KEY_SCORE = 'score';
16
17
    /**
18
     * @var string
19
     */
20
    const KEY_ID = 'tone_id';
21
22
    /**
23
     * @var string
24
     */
25
    const KEY_NAME = 'tone_name';
26
27
    /**
28
     * @var float
29
     */
30
    private $score;
31
32
    /**
33
     * @var string
34
     */
35
    private $id;
36
37
    /**
38
     * @var string
39
     */
40
    private $name;
41
42
    /**
43
     * @param float  $score
44
     * @param string $id
45
     * @param string $name
46
     */
47
    public function __construct($score, $id, $name)
48
    {
49
        $this->score = $score;
50
        $this->id    = $id;
51
        $this->name  = $name;
52
    }
53
54
    /**
55
     * @param array $data
56
     *
57
     * @return \IBM\Watson\ToneAnalyzer\Model\ToneScore
58
     */
59
    public static function create(array $data)
60
    {
61
        return new self(
62
            $data[static::KEY_SCORE],
63
            $data[static::KEY_ID],
64
            $data[static::KEY_NAME]
65
        );
66
    }
67
68
    /**
69
     * @return float
70
     */
71
    public function getScore()
72
    {
73
        return $this->score;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getId()
80
    {
81
        return $this->id;
82
    }
83
84
    /**
85
     * @return string
86
     */
87
    public function getName()
88
    {
89
        return $this->name;
90
    }
91
}
92