Phrases   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 10
c 1
b 0
f 0
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A processPhrases() 0 20 6
1
<?php
2
3
namespace detox\core;
4
5
class Phrases extends Words
6
{
7
    /**
8
     * Finds phrases from *Set and sets score/replacements
9
     */
10
    public function processPhrases()
11
    {
12
        // to match lower case letters in words set array
13
        $lowerSource = $this->addLowSpaces($this->text->getString());
14
        /**
15
         * @var string $points
16
         * @var array $phrases
17
         */
18
        foreach ($this->dataSet->getPhrases() as $points => $phrases) {
19
            foreach ($phrases as $phrase) {
20
                if (mb_strpos($lowerSource, ' ' . $phrase . ' ') !== false) {
21
                    $this->score += (float)$points;
22
                    if ($this->text->isReplaceable()) {
23
                        $this->replace($phrase);
24
                    }
25
                }
26
            }
27
        }
28
        if ($this->score >= self::MAX_SCORE) {
29
            $this->score = self::MAX_SCORE;
30
        }
31
    }
32
}