Russian   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 8
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B decide() 0 12 7
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Polyglot\Pluralization\Rules;
6
7
/**
8
 * @package Polyglot/Pluralization/Rules
9
 * @author  Mihai MATEI <[email protected]>
10
 */
11
class Russian implements RuleInterface
12
{
13
    /**
14
     * @inheritDoc
15
     */
16
    public function decide(int $n): int
17
    {
18
        $lastTwo = $n % 100;
19
        $end = $lastTwo % 10;
20
21
        if ($lastTwo !== 11 && $end === 1) {
22
            return 0;
23
        }
24
        if (2 <= $end && $end <= 4 && !($lastTwo >= 12 && $lastTwo <= 14)) {
25
            return 1;
26
        }
27
        return 2;
28
    }
29
}