Total Complexity | 5 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | class DocumentAnalysis implements CreatableFromArray |
||
13 | { |
||
14 | const KEY_TONES = 'tones'; |
||
15 | const KEY_WARNING = 'warning'; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private $tones; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $warning; |
||
26 | |||
27 | /** |
||
28 | * @param array $tones Array of ToneScore objects. |
||
29 | * @param string $warning Warning from response. |
||
30 | */ |
||
31 | public function __construct(array $tones, string $warning = null) |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Create DocumentAnalysis object from array. |
||
39 | * |
||
40 | * @param array $data |
||
41 | * |
||
42 | * @return \IBM\Watson\Common\Model\CreatableFromArray |
||
43 | */ |
||
44 | public static function create(array $data): CreatableFromArray |
||
45 | { |
||
46 | $warning = null; |
||
47 | |||
48 | if (isset($data[static::KEY_WARNING])) { |
||
49 | $warning = $data[static::KEY_WARNING]; |
||
50 | } |
||
51 | |||
52 | return new self($data[static::KEY_TONES], $warning); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Get DocumentAnalysis tones. |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | public function getTones(): array |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Get warning. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function getWarning(): string |
||
73 | } |
||
74 | } |
||
75 |