Completed
Push — master ( ff0c9a...939286 )
by f
23:01
created

src/Russian/GeographicalNamesInflection.php (47 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace morphos\Russian;
3
4
use morphos\S;
5
6
/**
7
 * Rules are from: https://ru.wikipedia.org/wiki/%D0%A1%D0%BA%D0%BB%D0%BE%D0%BD%D0%B5%D0%BD%D0%B8%D0%B5_%D0%B3%D0%B5%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D1%85_%D0%BD%D0%B0%D0%B7%D0%B2%D0%B0%D0%BD%D0%B8%D0%B9_%D0%B2_%D1%80%D1%83%D1%81%D1%81%D0%BA%D0%BE%D0%BC_%D1%8F%D0%B7%D1%8B%D0%BA%D0%B5
8
 */
9
class GeographicalNamesInflection extends \morphos\BaseInflection implements Cases
10
{
11
    use RussianLanguage, CasesHelper;
12
13
    protected static $abbreviations = [
14
        'сша',
15
        'оаэ',
16
        'ссср',
17
        'юар',
18
    ];
19
20
    protected static $delimiters = [
21
        ' ',
22
        '-на-',
23
        '-',
24
    ];
25
26
    protected static $ovAbnormalExceptions = [
27
        'осташков',
28
    ];
29
30
    protected static $immutableParts = [
31
        'санкт',
32
    ];
33
34
    /**
35
     * Проверяет, склоняемо ли название
36
     * @param string $name Название
37
     * @return bool
38
     */
39 2
    public static function isMutable($name)
40
    {
41 2
        $name = S::lower($name);
42
43
        // // ends with 'ы' or 'и': plural form
44
        // if (in_array(S::slice($name, -1), array('и', 'ы')))
45
        //     return false;
46
47 2
        if (in_array($name, self::$abbreviations, true) || in_array($name, self::$immutableParts, true)) {
48 2
            return false;
49
        }
50
51
        // N край
52
        if (S::slice($name, -5) == ' край') {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 41 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
53
            return static::isMutable(S::slice($name, 0, -5));
0 ignored issues
show
It seems like \morphos\S::slice($name, 0, -5) targeting morphos\S::slice() can also be of type false; however, morphos\Russian\Geograph...Inflection::isMutable() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
It seems like $name defined by \morphos\S::lower($name) on line 41 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
54
        }
55
56
        // N область
57
        if (S::slice($name, -8) == ' область') {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 41 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
58
            return true;
59
        }
60
61
        // город N
62
        if (S::slice($name, 0, 6) == 'город ') {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 41 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
63
            return true;
64
        }
65
66
        // село N
67
        if (S::slice($name, 0, 5) == 'село ') {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 41 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
68
            return true;
69
        }
70
71
        // хутор N
72
        if (S::slice($name, 0, 6) == 'хутор ') {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 41 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
73
            return true;
74
        }
75
76
        // пгт N
77
        if (S::slice($name, 0, 4) == 'пгт ') {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 41 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
78
            return false;
79
        }
80
81
        // ends with 'е' or 'о', but not with 'ово/ёво/ево/ино/ыно'
82
        if (in_array(S::slice($name, -1), ['е', 'о'], true) && !in_array(S::slice($name, -3, -1), ['ов', 'ёв', 'ев', 'ин', 'ын'], true)) {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 41 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
83
            return false;
84
        }
85
        return true;
86
    }
87
88
    /**
89
     * Получение всех форм названия
90
     * @param string $name
91
     * @return array
92
     * @throws \Exception
93
     */
94 32
    public static function getCases($name)
95
    {
96 32
        $name = S::lower($name);
97
98 32
        if (in_array($name, self::$immutableParts, true)) {
99 1
            return array_fill_keys([self::IMENIT, self::RODIT, self::DAT, self::VINIT, self::TVORIT, self::PREDLOJ], S::name($name));
100
        }
101
102 32
        if (strpos($name, ' ') !== false) {
103 7
            $first_part = S::slice($name, 0, S::findFirstPosition($name, ' '));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::findFirstPosition() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
104
            // город N, село N, хутор N, пгт N
105 7
            if (in_array($first_part, ['город', 'село', 'хутор', 'пгт'], true)) {
106 2
                if ($first_part !== 'пгт')
107 2
                    return self::composeCasesFromWords([
108 2
                        NounDeclension::getCases($first_part),
109 2
                        array_fill_keys(self::getAllCases(), S::name(S::slice($name, S::length($first_part) + 1)))
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
110
                    ]);
111
                else
112
                    return array_fill_keys([self::IMENIT, self::RODIT, self::DAT, self::VINIT, self::TVORIT, self::PREDLOJ], 'пгт '.S::name(S::slice($name, 4)));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
113
            }
114
115 5
            $last_part = S::slice($name,
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
116 5
                S::findLastPosition($name, ' ') + 1);
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::findLastPosition() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
117
            // N область, N край
118 5
            if (in_array($last_part, ['край', 'область'], true)) {
119 2
                return self::composeCasesFromWords([static::getCases(S::slice($name, 0, S::findLastPosition($name, ' '))), NounDeclension::getCases($last_part)]);
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::findLastPosition() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
It seems like \morphos\S::slice($name,...stPosition($name, ' ')) targeting morphos\S::slice() can also be of type false; however, morphos\Russian\Geograph...sInflection::getCases() does only seem to accept string, did you maybe forget to handle an error condition?
Loading history...
120
            }
121
        }
122
123
        // Сложное название через пробел, '-' или '-на-'
124 30
        foreach (self::$delimiters as $delimiter) {
125 30
            if (strpos($name, $delimiter) !== false) {
126 5
                $parts = explode($delimiter, $name);
127 5
                $result = [];
128 5
                foreach ($parts as $i => $part) {
129 5
                    $result[$i] = static::getCases($part);
130
                }
131 30
                return self::composeCasesFromWords($result, $delimiter);
132
            }
133
        }
134
135 30
        if (!in_array($name, self::$abbreviations, true)) {
136 28
            switch (S::slice($name, -2)) {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
137
                // Нижний, Русский
138 28
                case 'ий':
139 2
                    $prefix = S::name(S::slice($name, 0, -2));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
140
                    return [
141 2
                        self::IMENIT => $prefix . 'ий',
142 2
                        self::RODIT => $prefix . (self::isVelarConsonant(S::slice($name, -3, -2)) ? 'ого' : 'его'),
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
143 2
                        self::DAT => $prefix . (self::isVelarConsonant(S::slice($name, -3, -2)) ? 'ому' : 'ему'),
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
144 2
                        self::VINIT => $prefix . 'ий',
145 2
                        self::TVORIT => $prefix . 'им',
146 2
                        self::PREDLOJ => $prefix . (self::chooseEndingBySonority($prefix, 'ем', 'ом')),
0 ignored issues
show
It seems like $prefix defined by \morphos\S::name(\morphos\S::slice($name, 0, -2)) on line 139 can also be of type false; however, morphos\Russian\RussianL...hooseEndingBySonority() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
147
                    ];
148
149
                // Ростовская
150 27
                case 'ая':
151 1
                    $prefix = S::name(S::slice($name, 0, -2));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
152
                    return [
153 1
                        self::IMENIT => $prefix . 'ая',
154 1
                        self::RODIT => $prefix . 'ой',
155 1
                        self::DAT => $prefix . 'ой',
156 1
                        self::VINIT => $prefix . 'ую',
157 1
                        self::TVORIT => $prefix . 'ой',
158 1
                        self::PREDLOJ => $prefix . 'ой',
159
                    ];
160
161
                // Грозный, Благодарный
162 26
                case 'ый':
163 2
                    $prefix = S::name(S::slice($name, 0, -2));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
164
                    return [
165 2
                        self::IMENIT => $prefix . 'ый',
166 2
                        self::RODIT => $prefix . 'ого',
167 2
                        self::DAT => $prefix . 'ому',
168 2
                        self::VINIT => $prefix . 'ый',
169 2
                        self::TVORIT => $prefix . 'ым',
170 2
                        self::PREDLOJ => $prefix . 'ом',
171
                    ];
172
173
                // Ставрополь, Ярославль
174 24
                case 'ль':
175 1
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
176
                    return [
177 1
                        self::IMENIT => $prefix . 'ь',
178 1
                        self::RODIT => $prefix . 'я',
179 1
                        self::DAT => $prefix . 'ю',
180 1
                        self::VINIT => $prefix . 'ь',
181 1
                        self::TVORIT => $prefix . 'ем',
182 1
                        self::PREDLOJ => $prefix . 'е',
183
                    ];
184
185
                // Тверь, Анадырь
186 23
                case 'рь':
187 2
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
188 2
                    $last_vowel = S::slice($prefix, -2, -1);
0 ignored issues
show
It seems like $prefix defined by \morphos\S::name(\morphos\S::slice($name, 0, -1)) on line 187 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
189
                    return [
190 2
                        self::IMENIT => $prefix . 'ь',
191 2
                        self::RODIT => $prefix . (self::isBinaryVowel($last_vowel) ? 'и' : 'я'),
192 2
                        self::DAT => $prefix . (self::isBinaryVowel($last_vowel) ? 'и' : 'ю'),
193 2
                        self::VINIT => $prefix . 'ь',
194 2
                        self::TVORIT => $prefix . (self::isBinaryVowel($last_vowel) ? 'ью' : 'ем'),
195 2
                        self::PREDLOJ => $prefix . (self::isBinaryVowel($last_vowel) ? 'и' : 'е'),
196
                    ];
197
198
                // Березники, Ессентуки
199 21
                case 'ки':
200 2
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
201
                    return [
202 2
                        self::IMENIT => $prefix . 'и',
203 2
                        self::RODIT => $name == 'луки' ? $prefix : $prefix . 'ов',
204 2
                        self::DAT => $prefix . 'ам',
205 2
                        self::VINIT => $prefix . 'и',
206 2
                        self::TVORIT => $prefix . 'ами',
207 2
                        self::PREDLOJ => $prefix . 'ах',
208
                    ];
209
210
                // Пермь, Кемь
211 20
                case 'мь':
212 1
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
213
                    return [
214 1
                        self::IMENIT => $prefix . 'ь',
215 1
                        self::RODIT => $prefix . 'и',
216 1
                        self::DAT => $prefix . 'и',
217 1
                        self::VINIT => $prefix . 'ь',
218 1
                        self::TVORIT => $prefix . 'ью',
219 1
                        self::PREDLOJ => $prefix . 'и',
220
                    ];
221
222
                // Рязань, Назрань
223 19
                case 'нь':
224 1
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
225
                    return [
226 1
                        self::IMENIT => $prefix . 'ь',
227 1
                        self::RODIT => $prefix . 'и',
228 1
                        self::DAT => $prefix . 'и',
229 1
                        self::VINIT => $prefix . 'ь',
230 1
                        self::TVORIT => $prefix . 'ью',
231 1
                        self::PREDLOJ => $prefix . 'и',
232
                    ];
233
234
                // Набережные
235 18
                case 'ые':
236 1
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
237
                    return [
238 1
                        self::IMENIT => $prefix . 'е',
239 1
                        self::RODIT => $prefix . 'х',
240 1
                        self::DAT => $prefix . 'м',
241 1
                        self::VINIT => $prefix . 'е',
242 1
                        self::TVORIT => $prefix . 'ми',
243 1
                        self::PREDLOJ => $prefix . 'х',
244
                    ];
245
246
                // Челны
247 18
                case 'ны':
248 1
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
249
                    return [
250 1
                        self::IMENIT => $prefix . 'ы',
251 1
                        self::RODIT => $prefix . 'ов',
252 1
                        self::DAT => $prefix . 'ам',
253 1
                        self::VINIT => $prefix . 'ы',
254 1
                        self::TVORIT => $prefix . 'ами',
255 1
                        self::PREDLOJ => $prefix . 'ах',
256
                    ];
257
258
                // Великие
259 17
                case 'ие':
260 1
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
261
                    return [
262 1
                        self::IMENIT => $prefix.'е',
263 1
                        self::RODIT => $prefix.'х',
264 1
                        self::DAT => $prefix.'м',
265 1
                        self::VINIT => $prefix.'е',
266 1
                        self::TVORIT => $prefix.'ми',
267 1
                        self::PREDLOJ => $prefix.'х',
268
                    ];
269
270
                // Керчь
271 16
                case 'чь':
272 1
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
273
                    return [
274 1
                        self::IMENIT => $prefix.'ь',
275 1
                        self::RODIT => $prefix.'и',
276 1
                        self::DAT => $prefix.'и',
277 1
                        self::VINIT => $prefix.'ь',
278 1
                        self::TVORIT => $prefix.'ью',
279 1
                        self::PREDLOJ => $prefix.'и',
280
                    ];
281
            }
282
283
284 15
            switch (S::slice($name, -1)) {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
285
                // Азия
286 15
                case 'я':
287 1
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
288
                    return [
289 1
                        self::IMENIT => S::name($name),
290 1
                        self::RODIT => $prefix.'и',
291 1
                        self::DAT => $prefix.'и',
292 1
                        self::VINIT => $prefix.'ю',
293 1
                        self::TVORIT => $prefix.'ей',
294 1
                        self::PREDLOJ => $prefix.'и',
295
                    ];
296
297 14 View Code Duplication
                case 'а':
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
298
                    // Москва, Рига
299 5
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
300
                    return [
301 5
                        self::IMENIT => $prefix.'а',
302 5
                        self::RODIT => $prefix.(self::isVelarConsonant(S::slice($name, -2, -1)) ? 'и' : 'ы'),
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
303 5
                        self::DAT => $prefix.'е',
304 5
                        self::VINIT => $prefix.'у',
305 5
                        self::TVORIT => $prefix.'ой',
306 5
                        self::PREDLOJ => $prefix.'е',
307
                    ];
308
309 9
                case 'й':
310
                    // Ишимбай
311 2
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
312
                    return [
313 2
                        self::IMENIT => $prefix . 'й',
314 2
                        self::RODIT => $prefix . 'я',
315 2
                        self::DAT => $prefix . 'ю',
316 2
                        self::VINIT => $prefix . 'й',
317 2
                        self::TVORIT => $prefix . 'ем',
318 2
                        self::PREDLOJ => $prefix . 'е',
319
                    ];
320
            }
321
322 7
            if (self::isConsonant(S::slice($name,  -1)) && !in_array($name, self::$ovAbnormalExceptions, true)) {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
323
                // Париж, Валаам, Киев
324 6
                $prefix = S::name($name);
325
                return [
326 6
                    self::IMENIT => $prefix,
327 6
                    self::RODIT => $prefix . 'а',
328 6
                    self::DAT => $prefix . 'у',
329 6
                    self::VINIT => $prefix,
330 6
                    self::TVORIT => $prefix . (self::isVelarConsonant(S::slice($name, -2, -1)) ? 'ем' : 'ом'),
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
331 6
                    self::PREDLOJ => $prefix . 'е',
332
                ];
333
            }
334
335
            // ов, ово, ёв, ёво, ев, ево, ...
336 2
            $suffixes = ['ов', 'ёв', 'ев', 'ин', 'ын'];
337 2
            if ((in_array(S::slice($name, -1), ['е', 'о'], true) && in_array(S::slice($name, -3, -1), $suffixes, true)) || in_array(S::slice($name, -2), $suffixes, true)) {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
338
                // ово, ёво, ...
339 1
                if (in_array(S::slice($name, -3, -1), $suffixes, true)) {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
340
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
341
                }
342
                // ов, её, ...
343 1
                elseif (in_array(S::slice($name, -2), $suffixes, true)) {
0 ignored issues
show
It seems like $name defined by \morphos\S::lower($name) on line 96 can also be of type false; however, morphos\S::slice() does only seem to accept string, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
344 1
                    $prefix = S::name($name);
345
                }
346
                return [
347 1
                    self::IMENIT => S::name($name),
348 1
                    self::RODIT => $prefix.'а',
349 1
                    self::DAT => $prefix.'у',
350 1
                    self::VINIT => S::name($name),
351 1
                    self::TVORIT => $prefix.'ым',
352 1
                    self::PREDLOJ => $prefix.'е',
353
                ];
354
            }
355
        }
356
357
        // if no rules matches or name is immutable
358 3
        $name = in_array($name, self::$abbreviations, true) ? S::upper($name) : S::name($name);
359 3
        return array_fill_keys([self::IMENIT, self::RODIT, self::DAT, self::VINIT, self::TVORIT, self::PREDLOJ], $name);
360
    }
361
362
    /**
363
     * Получение одной формы (падежа) названия.
364
     * @param string $name  Название
365
     * @param integer $case Падеж. Одна из констант \morphos\Russian\Cases или \morphos\Cases.
366
     * @see \morphos\Russian\Cases
367
     * @return string
368
     * @throws \Exception
369
     */
370
    public static function getCase($name, $case)
371
    {
372
        $case = self::canonizeCase($case);
373
        $forms = self::getCases($name);
374
        return $forms[$case];
375
    }
376
}
377