DictionaryEntryPos::getPos()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace GinoPane\PHPolyglot\API\Response\Dictionary\Entry\POS;
4
5
use GinoPane\PHPolyglot\Supplemental\GetConstantsTrait;
6
7
/**
8
 * Class DictionaryPos
9
 *
10
 * Contains
11
 *
12
 * @link http://partofspeech.org/
13
 *
14
 * @author Sergey <Gino Pane> Karavay
15
 */
16
class DictionaryEntryPos
17
{
18
    const POS_UNDEFINED     = '';
19
    const POS_NOUN          = 'noun';
20
    const POS_PRONOUN       = 'pronoun';
21
    const POS_VERB          = 'verb';
22
    const POS_ADVERB        = 'adverb';
23
    const POS_ADJECTIVE     = 'adjective';
24
    const POS_CONJUCTION    = 'conjuction';
25
    const POS_PREPOSITION   = 'preposition';
26
    const POS_INTERJECTION  = 'interjection';
27
28
    /**
29
     * Stored part of speech
30
     *
31
     * @var string
32
     */
33
    private $pos = self::POS_UNDEFINED;
34
35
    use GetConstantsTrait;
36
37
    /**
38
     * DictionaryEntryPos constructor
39
     *
40
     * @param string $pos
41
     */
42
    public function __construct(string $pos = self::POS_UNDEFINED)
43
    {
44
        $pos = strtolower($pos);
45
46
        if ($this->constantValueExists($pos)) {
47
            $this->pos = $pos;
48
        } else {
49
            $this->pos = self::POS_UNDEFINED;
50
        }
51
    }
52
53
    /**
54
     * Returns part of speech as string
55
     *
56
     * @return string
57
     */
58
    public function getPos(): string
59
    {
60
        return $this->pos;
61
    }
62
}
63