Completed
Push — develop ( 5fc40e...dcac96 )
by Adam
13s
created

Utterance::getTones()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace IBM\Watson\ToneAnalyzer\Model;
4
5
use IBM\Watson\Common\Model\ApiResponseInterface;
6
7 View Code Duplication
class Utterance implements ApiResponseInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * @var int
11
     */
12
    private $utteranceId;
13
14
    /**
15
     * @var string
16
     */
17
    private $text;
18
19
    /**
20
     * @var array
21
     */
22
    private $tones;
23
24
    /**
25
     * Utterance constructor.
26
     *
27
     * @param int       $utteranceId
28
     * @param string    $text
29
     * @param array     $tones
30
     */
31 3
    public function __construct($utteranceId, $text, array $tones)
32
    {
33 3
        $this->utteranceId = $utteranceId;
34 3
        $this->text = $text;
35 3
        $this->tones = $tones;
36 3
    }
37
38
    /**
39
     * Create individual utterance
40
     *
41
     * @param array $data
42
     *
43
     * @return \IBM\Watson\ToneAnalyzer\Model\Utterance
44
     */
45 3
    public static function create(array $data)
46
    {
47 3
        $tones = [];
48
49 3
        foreach ($data['tones'] as $tone) {
50 3
            $tones[] = Tone::create($tone);
51 1
        }
52
53 3
        return new self($data['utterance_id'], $data['utterance_text'], $tones);
54
    }
55
56
    /**
57
     * Get utterance id
58
     *
59
     * @return int
60
     */
61 3
    public function getId()
62
    {
63 3
        return $this->utteranceId;
64
    }
65
66
    /**
67
     * Get utterance text
68
     *
69
     * @return string
70
     */
71 3
    public function getText()
72
    {
73 3
        return $this->text;
74
    }
75
76
    /**
77
     * Get utterance tones
78
     *
79
     * @return array
80
     */
81 3
    public function getTones()
82
    {
83 3
        return $this->tones;
84
    }
85
}
86