Phrases::processPhrases()   A
last analyzed

Complexity

Conditions 6
Paths 10

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 20
rs 9.2222
cc 6
nc 10
nop 0
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
}