DictionaryTranslation::__construct()   B
last analyzed

Complexity

Conditions 7
Paths 12

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 7

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 12
cts 12
cp 1
rs 8.6346
c 0
b 0
f 0
cc 7
nc 12
nop 1
crap 7
1
<?php
2
/**
3
 * Yandex PHP Library
4
 *
5
 * @copyright NIX Solutions Ltd.
6
 * @link https://github.com/nixsolutions/yandex-php-library
7
 */
8
9
/**
10
 * @namespace
11
 */
12
namespace Yandex\Dictionary;
13
14
/**
15
 * Class DictionaryTranslation
16
 *
17
 * @category Yandex
18
 * @package  Dictionary
19
 *
20
 * @author   Nikolay Oleynikov <[email protected]>
21
 * @created  07.11.14 20:05
22
 */
23
class DictionaryTranslation extends DictionaryBaseItem
24
{
25
    /**
26
     * @var
27
     */
28
    protected $synonyms = [];
29
30
    /**
31
     * @var
32
     */
33
    protected $meanings = [];
34
35
    /**
36
     * @var
37
     */
38
    protected $examples = [];
39
40
    /**
41
     *
42
     */
43 2
    public function __construct($translation)
44
    {
45 2
        parent::__construct($translation);
46
47 2
        if (isset($translation->syn)) {
48 1
            foreach ($translation->syn as $synonym) {
49 1
                $this->synonyms[] = new DictionaryBaseItem($synonym);
50
            }
51
        }
52
53 2
        if (isset($translation->mean)) {
54 2
            foreach ($translation->mean as $meaning) {
55 2
                $this->meanings[] = new DictionaryBaseItem($meaning);
56
            }
57
        }
58
59 2
        if (isset($translation->ex)) {
60 1
            foreach ($translation->ex as $example) {
61 1
                $this->examples[] = new DictionaryExample($example);
62
            }
63
        }
64 2
    }
65
66
    /**
67
     *  @return array
68
     */
69 1
    public function getSynonyms()
70
    {
71 1
        return $this->synonyms;
72
    }
73
74
    /**
75
     *  @return array
76
     */
77 1
    public function getMeanings()
78
    {
79 1
        return $this->meanings;
80
    }
81
82
    /**
83
     *  @return array
84
     */
85 1
    public function getExamples()
86
    {
87 1
        return $this->examples;
88
    }
89
}
90