| Conditions | 5 |
| Paths | 6 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function processPhrases(string $source) |
||
| 11 | { |
||
| 12 | // to match lower case letters in words set array |
||
| 13 | $lowerSource = $this->addLowSpaces($source); |
||
| 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 | } |
||
| 23 | if ($this->score >= self::MAX_SCORE) { |
||
| 24 | $this->score = self::MAX_SCORE; |
||
| 25 | |||
| 26 | // we don't need to iterate more with max score |
||
| 27 | return; |
||
| 28 | } |
||
| 32 | } |