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

DictionaryBaseItem::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 9.4285
cc 3
eloc 5
nc 4
nop 1
crap 3
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 DictionaryBaseItem
16
 *
17
 * @category Yandex
18
 * @package  Dictionary
19
 *
20
 * @author   Nikolay Oleynikov <[email protected]>
21
 * @created  07.11.14 20:38
22
 */
23
class DictionaryBaseItem
24
{
25
    /**
26
     * @var
27
     */
28
    protected $text;
29
30
    /**
31
     * @var
32
     */
33
    protected $partOfSpeech;
34
35
    /**
36
     *
37
     */
38 2
    public function __construct($item)
39
    {
40 2
        if (isset($item->text)) {
41 2
            $this->text = $item->text;
42 2
        }
43
44 2
        if (isset($item->pos)) {
45 2
            $this->partOfSpeech = $item->pos;
46 2
        }
47 2
    }
48
49
    /**
50
     * @return string
51
     */
52 2
    public function __toString()
53
    {
54 2
        return $this->getText();
55
    }
56
57
    /**
58
     *  @return string
59
     */
60 2
    public function getText()
61
    {
62 2
        return $this->text;
63
    }
64
65
    /**
66
     *  @return string
67
     */
68 2
    public function getPartOfSpeech()
69
    {
70 2
        return $this->partOfSpeech;
71
    }
72
}
73