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

DictionaryDefinition::__construct()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 14
ccs 11
cts 11
cp 1
rs 9.2
cc 4
eloc 7
nc 6
nop 1
crap 4
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 DictionaryDefinition
16
 *
17
 * @category Yandex
18
 * @package  Dictionary
19
 *
20
 * @author   Nikolay Oleynikov <[email protected]>
21
 * @created  07.11.14 19:55
22
 */
23
class DictionaryDefinition extends DictionaryBaseItem
24
{
25
    /**
26
     * @var
27
     */
28
    protected $transcription;
29
30
    /**
31
     * @var
32
     */
33
    protected $translations = [];
34
35
    /**
36
     *
37
     */
38 2
    public function __construct($definition)
39
    {
40 2
        parent::__construct($definition);
41
42 2
        if (isset($definition->ts)) {
43 2
            $this->transcription = $definition->ts;
44 2
        }
45
46 2
        if (isset($definition->tr)) {
47 2
            foreach ($definition->tr as $translation) {
48 2
                $this->translations[] = new DictionaryTranslation($translation);
49 2
            }
50 2
        }
51 2
    }
52
53
    /**
54
     *  @return string
55
     */
56 1
    public function getTranscription()
57
    {
58 1
        return $this->transcription;
59
    }
60
61
    /**
62
     *  @return array
63
     */
64 2
    public function getTranslations()
65
    {
66 2
        return $this->translations;
67
    }
68
}
69