Completed
Pull Request — develop (#5)
by Adam
01:26
created

ToneAnalysis::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace IBM\Watson\ToneAnalyzer\Model;
4
5
use IBM\Watson\Common\Model\ApiResponse;
6
7
class ToneAnalysis implements ApiResponse
8
{
9
    /**
10
     * @var \IBM\Watson\ToneAnalyzer\Model\DocumentAnalysis
11
     */
12
    private $documentAnalysis;
13
14
    /**
15
     * @var \IBM\Watson\ToneAnalyzer\Model\SentenceAnalysis
16
     */
17
    private $sentenceAnalysis;
18
19
    /**
20
     * ToneAnalysis constructor.
21
     *
22
     * @param \IBM\Watson\ToneAnalyzer\Model\DocumentAnalysis $documentAnalysis
23
     * @param \IBM\Watson\ToneAnalyzer\Model\SentenceAnalysis $sentenceAnalysis
24
     */
25
    public function __construct(DocumentAnalysis $documentAnalysis, SentenceAnalysis $sentenceAnalysis)
26
    {
27
        $this->documentAnalysis = $documentAnalysis;
28
        $this->sentenceAnalysis = $sentenceAnalysis;
29
    }
30
31
    /**
32
     * Create tone analysis
33
     *
34
     * @param array $data
35
     *
36
     * @return \IBM\Watson\ToneAnalyzer\Model\ToneAnalysis
37
     */
38
    public static function create(array $data)
39
    {
40
        $documentAnalysis = DocumentAnalysis::create($data);
41
        $sentenceAnalysis = SentenceAnalysis::create($data);
42
43
        return new self($documentAnalysis, $sentenceAnalysis);
44
    }
45
46
    /**
47
     * Get document level analysis
48
     *
49
     * @return \IBM\Watson\ToneAnalyzer\Model\DocumentAnalysis
50
     */
51
    public function getDocumentAnalysis()
52
    {
53
        return $this->documentAnalysis;
54
    }
55
56
    /**
57
     * Get sentence level analysis
58
     *
59
     * @return \IBM\Watson\ToneAnalyzer\Model\SentenceAnalysis
60
     */
61
    public function getSentenceAnalysis()
62
    {
63
        return $this->sentenceAnalysis;
64
    }
65
}
66