Completed
Pull Request — master (#151)
by Alexander
04:33
created

DictionaryTranslation::getSynonyms()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
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 1
            }
51 1
        }
52
53 2
        if (isset($translation->mean)) {
54 2
            foreach ($translation->mean as $meaning) {
55 2
                $this->meanings[] = new DictionaryBaseItem($meaning);
56 2
            }
57 2
        }
58
59 2
        if (isset($translation->ex)) {
60 1
            foreach ($translation->ex as $example) {
61 1
                $this->examples[] = new DictionaryExample($example);
62 1
            }
63 1
        }
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