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

DictionaryBaseItem::getPartOfSpeech()   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 0
Metric Value
c 1
b 0
f 0
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 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