ArticleWord::stemm()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Mystem;
3
4
/**
5
 * Class ArticleWord
6
 *
7
 * Initialized from Article class, has link to original article and $position, filled with in Article position
8
 * @package Mystem
9
 */
10
class ArticleWord extends Word
11
{
12
13
    protected static $constructorClass = '\Mystem\ArticleWord';
14
15
    /**
16
     * @var string $article link to original article string
17
     */
18
    protected $article;
19
20
    public $position;
21
22
    /**
23
     * @param array|string $lexicalString
24
     * @param int $maxVariants
25
     * @param string $article
26
     * @return ArticleWord
27
     */
28 4
    public static function newFromLexicalString($lexicalString, $maxVariants = null, &$article = null)
29
    {
30
        /* @var ArticleWord $word */
31 4
        $word = parent::newFromLexicalString($lexicalString, $maxVariants);
32 4
        if ($article !== null) {
33 4
            $word->article = &$article;
34 4
        }
35 4
        return $word;
36
    }
37
38
    /**
39
     * @param string $word
40
     * @param int $maxVariants
41
     * @param string $article
42
     * @return ArticleWord
43
     */
44 1
    public static function stemm($word, $maxVariants = null, &$article = null)
45
    {
46
        /* @var ArticleWord $word */
47 1
        $word = parent::stemm($word, $maxVariants);
48 1
        if ($article !== null) {
49 1
            $word->article = &$article;
50 1
        }
51 1
        return $word;
52
    }
53
}
54