Polish   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 5
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A decide() 0 9 6
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 Polish implements RuleInterface
12
{
13
    /**
14
     * @inheritDoc
15
     */
16
    public function decide(int $n): int
17
    {
18
        if ($n === 1) {
19
            return 0;
20
        }
21
22
        $end = $n % 10;
23
24
        return 2 <= $end && $end <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2;
25
    }
26
}