Completed
Push — develop ( 68a985...a1f82e )
by Adam
10s
created

DocumentAnalysis   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 44
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 9 2
A getTones() 0 4 1
1
<?php
2
3
namespace IBM\Watson\ToneAnalyzer\Model;
4
5
use IBM\Watson\Common\Model\ApiResponseInterface;
6
7
class DocumentAnalysis implements ApiResponseInterface
8
{
9
    /**
10
     * @var array
11
     */
12
    private $tones;
13
14
    /**
15
     * DocumentAnalysis constructor.
16
     *
17
     * @param $tones
18
     */
19 6
    public function __construct(array $tones = [])
20
    {
21 6
        $this->tones = $tones;
22 6
    }
23
24
    /**
25
     * Create document analysis
26
     *
27
     * @param array $data
28
     *
29
     * @return \IBM\Watson\ToneAnalyzer\Model\DocumentAnalysis
30
     */
31 6
    public static function create(array $data)
32
    {
33 6
        $tones = [];
34 6
        foreach ($data['document_tone']['tones'] as $tone) {
35 6
            $tones[] = Tone::create($tone);
36 4
        }
37
38 6
        return new self($tones);
39
    }
40
41
    /**
42
     * Get document tones
43
     *
44
     * @return array
45
     */
46 3
    public function getTones()
47
    {
48 3
        return $this->tones;
49
    }
50
}
51