WordStats   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 9
eloc 17
c 2
b 2
f 0
dl 0
loc 76
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getStopWordCount() 0 2 1
A getWordCount() 0 2 1
A setStopWords() 0 4 1
A setWordCount() 0 4 1
A setStopWordCount() 0 4 1
A getStopWords() 0 2 1
A __construct() 0 6 3
1
<?php declare(strict_types=1);
2
3
namespace Goose\Text;
4
5
/**
6
 * Word Stats
7
 *
8
 * @package Goose\Text
9
 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
10
 */
11
class WordStats
12
{
13
    /** @var int Total number of stopwords or good words that we can calculate */
14
    private $stopWordCount = 0;
15
16
    /** @var int Total number of words on a node */
17
    private $wordCount = 0;
18
19
    /** @var array Holds an actual list of the stop words we found */
20
    private $stopWords = [];
21
22
    /**
23
     * @param mixed[] $options
24
     */
25
    public function __construct($options = []) {
26
        foreach ($options as $key => $value) {
27
            $method = 'set' . ucfirst($key);
28
29
            if (method_exists($this, $method)) {
30
                call_user_func([$this, $method], $value);
31
            }
32
        }
33
    }
34
35
    /**
36
     * @return string[]
37
     */
38
    public function getStopWords(): array {
39
        return $this->stopWords;
40
    }
41
42
    /**
43
     * @param string[] $words
44
     *
45
     * @return self
46
     */
47
    public function setStopWords($words): self {
48
        $this->stopWords = $words;
49
50
        return $this;
51
    }
52
53
    /**
54
     * @return int
55
     */
56
    public function getStopWordCount(): int {
57
        return $this->stopWordCount;
58
    }
59
60
    /**
61
     * @param int $wordCount
62
     *
63
     * @return self
64
     */
65
    public function setStopWordCount(int $wordCount): self {
66
        $this->stopWordCount = $wordCount;
67
68
        return $this;
69
    }
70
71
    /**
72
     * @return int
73
     */
74
    public function getWordCount(): int {
75
        return $this->wordCount;
76
    }
77
78
    /**
79
     * @param int $wordCount
80
     *
81
     * @return self
82
     */
83
    public function setWordCount(int $wordCount): self {
84
        $this->wordCount = $wordCount;
85
86
        return $this;
87
    }
88
}