| Total Complexity | 6 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class Single extends BaseRank implements Declinable |
||
| 20 | { |
||
| 21 | /* @var int */ |
||
| 22 | private $gender; |
||
| 23 | |||
| 24 | private $genderMethodMap = [ |
||
| 25 | Declinable::TYPE_MASCULINE => 'getMasculineVariants', |
||
| 26 | Declinable::TYPE_FEMININE => 'getFeminineVariant', |
||
| 27 | ]; |
||
| 28 | |||
| 29 | protected $words = [ |
||
| 30 | 0 => '', |
||
| 31 | 1 => 'один', |
||
| 32 | 2 => 'два', |
||
| 33 | 3 => 'три', |
||
| 34 | 4 => 'четыре', |
||
| 35 | 5 => 'пять', |
||
| 36 | 6 => 'шесть', |
||
| 37 | 7 => 'семь', |
||
| 38 | 8 => 'восемь', |
||
| 39 | 9 => 'девять', |
||
| 40 | ]; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @inheritdoc |
||
| 44 | */ |
||
| 45 | public function getWord($key): string |
||
| 46 | { |
||
| 47 | if (!$this->gender) { |
||
| 48 | return $this->words[$key]; |
||
| 49 | } |
||
| 50 | $dependent = call_user_func([$this, $this->genderMethodMap[$this->gender]]); |
||
| 51 | return isset($dependent[$key]) ? $dependent[$key] : $this->words[$key]; |
||
| 52 | |||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @inheritdoc |
||
| 57 | */ |
||
| 58 | public function setGender($gender) |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Склонения для зависимых чисел в мужском роде |
||
| 65 | * |
||
| 66 | * @return array |
||
| 67 | */ |
||
| 68 | private function getMasculineVariants() |
||
| 69 | { |
||
| 70 | return [1 => 'один', 2 => 'два']; |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Склонения для зависимых чисел в женском роде |
||
| 75 | * |
||
| 76 | * @return array |
||
| 77 | */ |
||
| 78 | private function getFeminineVariant() |
||
| 81 | } |
||
| 82 | } |