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

UtteranceAnalyses::getTones()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace IBM\Watson\ToneAnalyzer\Model;
5
6
use IBM\Watson\Common\Model\CreateableFromArray;
7
8
/**
9
 * Class UtteranceAnalyses
10
 */
11 View Code Duplication
class UtteranceAnalyses implements CreateableFromArray
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...
12
{
13
    /**
14
     * @var string
15
     */
16
    const KEY_TONE = 'utterances_tone';
17
18
    /**
19
     * @var string
20
     */
21
    const KEY_WARNING = 'warning';
22
23
    /**
24
     * @var array
25
     */
26
    private $tones;
27
28
    /**
29
     * @var null|string
30
     */
31
    private $warning;
32
33
    /**
34
     * @param array       $tones
35
     * @param null|string $warning
36
     */
37
    public function __construct(array $tones, $warning = null)
38
    {
39
        $this->tones    = $tones;
40
        $this->warning = $warning;
41
    }
42
43
    /**
44
     * @param array $data
45
     *
46
     * @return \IBM\Watson\ToneAnalyzer\Model\UtteranceAnalyses
47
     */
48
    public static function create(array $data)
49
    {
50
        $tones = [];
51
        foreach ($data[static::KEY_TONE] as $tone) {
52
            $tones[] = UtteranceAnalysis::create($tone);
53
        }
54
55
        return new self($tones, isset($data[static::KEY_WARNING]) ? $data[static::KEY_WARNING] : null);
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    public function getTones()
62
    {
63
        return $this->tones;
64
    }
65
66
    /**
67
     * @return null
68
     */
69
    public function getWarning()
70
    {
71
        return $this->warning;
72
    }
73
}
74