Completed
Push — master ( d5b3dc...a0db8f )
by f
01:52
created

GeographicalNamesInflection   B

Complexity

Total Complexity 51

Size/Duplication

Total Lines 354
Duplicated Lines 10.17 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 86.7%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 36
loc 354
ccs 163
cts 188
cp 0.867
rs 8.3206
c 1
b 1
f 0
wmc 51
lcom 1
cbo 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
C isMutable() 0 48 11
D getCases() 36 253 39
A getCase() 0 6 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like GeographicalNamesInflection often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use GeographicalNamesInflection, and based on these observations, apply Extract Interface, too.

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) || in_array($name, self::$immutableParts)) {
48 2
            return false;
49
        }
50
51
        // N край
52
        if (S::slice($name, -5) == ' край') {
0 ignored issues
show
Security Bug introduced by
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
Security Bug introduced by
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...
Security Bug introduced by
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
Security Bug introduced by
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
Security Bug introduced by
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
Security Bug introduced by
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
Security Bug introduced by
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
Security Bug introduced by
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), ['е', 'о']) && !in_array(S::slice($name, -3, -1), ['ов', 'ёв', 'ев', 'ин', 'ын'])) {
0 ignored issues
show
Security Bug introduced by
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 30
    public static function getCases($name)
95
    {
96 30
        $name = S::lower($name);
97
98 30
        if (in_array($name, self::$immutableParts)) {
99 1
            return array_fill_keys([self::IMENIT, self::RODIT, self::DAT, self::VINIT, self::TVORIT, self::PREDLOJ], S::name($name));
100
        }
101
102
        // N край
103 30 View Code Duplication
        if (S::slice($name, -5) == ' край') {
0 ignored issues
show
Security Bug introduced by
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...
Duplication introduced by
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...
104 1
            return self::composeCasesFromWords([static::getCases(S::slice($name, 0, -5)), NounDeclension::getCases('край')]);
0 ignored issues
show
Security Bug introduced by
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...
Security Bug introduced by
It seems like \morphos\S::slice($name, 0, -5) 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...
105
        }
106
107
        // N область
108 30 View Code Duplication
        if (S::slice($name, -8) == ' область') {
0 ignored issues
show
Security Bug introduced by
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...
Duplication introduced by
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...
109 1
            return self::composeCasesFromWords([static::getCases(S::slice($name, 0, -8)), NounDeclension::getCases('область')]);
0 ignored issues
show
Security Bug introduced by
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...
Security Bug introduced by
It seems like \morphos\S::slice($name, 0, -8) 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...
110
        }
111
112
        // город N
113 30 View Code Duplication
        if (S::slice($name, 0, 6) == 'город ') {
0 ignored issues
show
Security Bug introduced by
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...
Duplication introduced by
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...
114 1
            return self::composeCasesFromWords([
115 1
                NounDeclension::getCases('город'),
116 1
                array_fill_keys(self::getAllCases(), S::name(S::slice($name, 6)))
0 ignored issues
show
Security Bug introduced by
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...
117
            ]);
118
        }
119
120
        // село N
121 29 View Code Duplication
        if (S::slice($name, 0, 5) == 'село ') {
0 ignored issues
show
Security Bug introduced by
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...
Duplication introduced by
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...
122 1
            return self::composeCasesFromWords([
123 1
                NounDeclension::getCases('село'),
124 1
                array_fill_keys(self::getAllCases(), S::name(S::slice($name, 5)))
0 ignored issues
show
Security Bug introduced by
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...
125
            ]);
126
        }
127
128
        // хутор N
129 28 View Code Duplication
        if (S::slice($name, 0, 6) == 'хутор ') {
0 ignored issues
show
Security Bug introduced by
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...
Duplication introduced by
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...
130
            return self::composeCasesFromWords([
131
                NounDeclension::getCases('хутор'),
132
                array_fill_keys(self::getAllCases(), S::name(S::slice($name, 6)))
0 ignored issues
show
Security Bug introduced by
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...
133
            ]);
134
        }
135
136
        // пгт N
137 28
        if (S::slice($name, 0, 4) == 'пгт ') {
0 ignored issues
show
Security Bug introduced by
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...
138
            return self::composeCasesFromWords([
139
                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
Security Bug introduced by
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
            ]);
141
        }
142
143
        // Сложное название через пробел, '-' или '-на-'
144 28
        foreach (self::$delimiters as $delimiter) {
145 28
            if (strpos($name, $delimiter) !== false) {
146 5
                $parts = explode($delimiter, $name);
147 5
                $result = [];
148 5
                foreach ($parts as $i => $part) {
149 5
                    $result[$i] = static::getCases($part);
150
                }
151 28
                return self::composeCasesFromWords($result, $delimiter);
152
            }
153
        }
154
155 28
        if (!in_array($name, self::$abbreviations)) {
156 26
            if (S::slice($name, -2) == 'ий') {
0 ignored issues
show
Security Bug introduced by
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...
157
                // Нижний, Русский
158 2
                $prefix = S::name(S::slice($name, 0, -2));
0 ignored issues
show
Security Bug introduced by
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...
159
                return [
160 2
                    self::IMENIT => $prefix.'ий',
161 2
                    self::RODIT => $prefix.(self::isVelarConsonant(S::slice($name, -3, -2)) ? 'ого' : 'его'),
0 ignored issues
show
Security Bug introduced by
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...
162 2
                    self::DAT => $prefix.(self::isVelarConsonant(S::slice($name, -3, -2)) ? 'ому' : 'ему'),
0 ignored issues
show
Security Bug introduced by
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...
163 2
                    self::VINIT => $prefix.'ий',
164 2
                    self::TVORIT => $prefix.'им',
165 2
                    self::PREDLOJ => $prefix.(self::chooseEndingBySonority($prefix, 'ем', 'ом')),
0 ignored issues
show
Security Bug introduced by
It seems like $prefix defined by \morphos\S::name(\morphos\S::slice($name, 0, -2)) on line 158 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...
166
                ];
167 25
            } else if (S::slice($name, -2) == 'ая') {
0 ignored issues
show
Security Bug introduced by
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...
168
                // Ростовская
169 1
                $prefix = S::name(S::slice($name, 0, -2));
0 ignored issues
show
Security Bug introduced by
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...
170
                return [
171 1
                    self::IMENIT => $prefix.'ая',
172 1
                    self::RODIT => $prefix.'ой',
173 1
                    self::DAT => $prefix.'ой',
174 1
                    self::VINIT => $prefix.'ую',
175 1
                    self::TVORIT => $prefix.'ой',
176 1
                    self::PREDLOJ => $prefix.'ой',
177
                ];
178 24
            } else if (S::slice($name, -2) == 'ый') {
0 ignored issues
show
Security Bug introduced by
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...
179
                // Грозный, Благодарный
180 2
                $prefix = S::name(S::slice($name, 0, -2));
0 ignored issues
show
Security Bug introduced by
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...
181
                return [
182 2
                    self::IMENIT => $prefix.'ый',
183 2
                    self::RODIT => $prefix.'ого',
184 2
                    self::DAT => $prefix.'ому',
185 2
                    self::VINIT => $prefix.'ый',
186 2
                    self::TVORIT => $prefix.'ым',
187 2
                    self::PREDLOJ => $prefix.'ом',
188
                ];
189 22 View Code Duplication
            } elseif (S::slice($name, -1) == 'а') {
0 ignored issues
show
Security Bug introduced by
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...
Duplication introduced by
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...
190
                // Москва, Рига
191 5
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
192
                return [
193 5
                    self::IMENIT => $prefix.'а',
194 5
                    self::RODIT => $prefix.(self::isVelarConsonant(S::slice($name, -2, -1)) ? 'и' : 'ы'),
0 ignored issues
show
Security Bug introduced by
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...
195 5
                    self::DAT => $prefix.'е',
196 5
                    self::VINIT => $prefix.'у',
197 5
                    self::TVORIT => $prefix.'ой',
198 5
                    self::PREDLOJ => $prefix.'е',
199
                ];
200 17
            } elseif (S::slice($name, -1) == 'я') {
0 ignored issues
show
Security Bug introduced by
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
                // Азия
202 1
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
203
                return [
204 1
                    self::IMENIT => S::name($name),
205 1
                    self::RODIT => $prefix.'и',
206 1
                    self::DAT => $prefix.'и',
207 1
                    self::VINIT => $prefix.'ю',
208 1
                    self::TVORIT => $prefix.'ей',
209 1
                    self::PREDLOJ => $prefix.'и',
210
                ];
211 16
            } elseif (S::slice($name, -1) == 'й') {
0 ignored issues
show
Security Bug introduced by
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...
212
                // Ишимбай
213 2
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
214
                return [
215 2
                    self::IMENIT => $prefix.'й',
216 2
                    self::RODIT => $prefix.'я',
217 2
                    self::DAT => $prefix.'ю',
218 2
                    self::VINIT => $prefix.'й',
219 2
                    self::TVORIT => $prefix.'ем',
220 2
                    self::PREDLOJ => $prefix.'е',
221
                ];
222 14
            } elseif (self::isConsonant(S::slice($name, -1)) && !in_array($name, self::$ovAbnormalExceptions)) {
0 ignored issues
show
Security Bug introduced by
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...
223
                // Париж, Валаам, Киев
224 6
                $prefix = S::name($name);
225
                return [
226 6
                    self::IMENIT => $prefix,
227 6
                    self::RODIT => $prefix.'а',
228 6
                    self::DAT => $prefix.'у',
229 6
                    self::VINIT => $prefix,
230 6
                    self::TVORIT => $prefix.(self::isVelarConsonant(S::slice($name, -2, -1)) ? 'ем' : 'ом'),
0 ignored issues
show
Security Bug introduced by
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...
231 6
                    self::PREDLOJ => $prefix.'е',
232
                ];
233 9
            } elseif (S::slice($name, -2) == 'ль') {
0 ignored issues
show
Security Bug introduced by
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...
234
                // Ставрополь, Ярославль
235 1
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
236
                return [
237 1
                    self::IMENIT => $prefix.'ь',
238 1
                    self::RODIT => $prefix.'я',
239 1
                    self::DAT => $prefix.'ю',
240 1
                    self::VINIT => $prefix.'ь',
241 1
                    self::TVORIT => $prefix.'ем',
242 1
                    self::PREDLOJ => $prefix.'е',
243
                ];
244 8
            } elseif (S::slice($name, -2) == 'рь') {
0 ignored issues
show
Security Bug introduced by
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...
245
                // Тверь
246 1
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
247
                return [
248 1
                    self::IMENIT => $prefix.'ь',
249 1
                    self::RODIT => $prefix.'и',
250 1
                    self::DAT => $prefix.'и',
251 1
                    self::VINIT => $prefix.'ь',
252 1
                    self::TVORIT => $prefix.'ью',
253 1
                    self::PREDLOJ => $prefix.'и',
254
                ];
255 7
            } elseif (S::slice($name, -2) == 'ки') {
0 ignored issues
show
Security Bug introduced by
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...
256
                // Березники, Ессентуки
257 2
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
258
                return [
259 2
                    self::IMENIT => $prefix.'и',
260 2
                    self::RODIT => $name == 'луки' ? $prefix : $prefix.'ов',
261 2
                    self::DAT => $prefix.'ам',
262 2
                    self::VINIT => $prefix.'и',
263 2
                    self::TVORIT => $prefix.'ами',
264 2
                    self::PREDLOJ => $prefix.'ах',
265
                ];
266 6
            } elseif (S::slice($name, -2) == 'мь') {
0 ignored issues
show
Security Bug introduced by
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...
267
                // Пермь, Кемь
268 1
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
269
                return [
270 1
                    self::IMENIT => $prefix.'ь',
271 1
                    self::RODIT => $prefix.'и',
272 1
                    self::DAT => $prefix.'и',
273 1
                    self::VINIT => $prefix.'ь',
274 1
                    self::TVORIT => $prefix.'ью',
275 1
                    self::PREDLOJ => $prefix.'и',
276
                ];
277 5
            } elseif (S::slice($name, -2) == 'нь') {
0 ignored issues
show
Security Bug introduced by
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...
278
                // Рязань, Назрань
279 1
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
280
                return [
281 1
                    self::IMENIT => $prefix.'ь',
282 1
                    self::RODIT => $prefix.'и',
283 1
                    self::DAT => $prefix.'и',
284 1
                    self::VINIT => $prefix.'ь',
285 1
                    self::TVORIT => $prefix.'ью',
286 1
                    self::PREDLOJ => $prefix.'и',
287
                ];
288 4
            } else if (S::slice($name, -2) == 'ые') {
0 ignored issues
show
Security Bug introduced by
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...
289
                // Набережные
290 1
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
291
                return [
292 1
                    self::IMENIT => $prefix.'е',
293 1
                    self::RODIT => $prefix.'х',
294 1
                    self::DAT => $prefix.'м',
295 1
                    self::VINIT => $prefix.'е',
296 1
                    self::TVORIT => $prefix.'ми',
297 1
                    self::PREDLOJ => $prefix.'х',
298
                ];
299 4
            } else if (S::slice($name, -2) == 'ны') {
0 ignored issues
show
Security Bug introduced by
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
                // Челны
301 1
                $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
302
                return [
303 1
                    self::IMENIT => $prefix.'ы',
304 1
                    self::RODIT => $prefix.'ов',
305 1
                    self::DAT => $prefix.'ам',
306 1
                    self::VINIT => $prefix.'ы',
307 1
                    self::TVORIT => $prefix.'ами',
308 1
                    self::PREDLOJ => $prefix.'ах',
309
                ];
310 3
            } else if ($name == 'великие') {
311 1
                $prefix = 'Велики';
312
                return [
313 1
                    self::IMENIT => $prefix.'е',
314 1
                    self::RODIT => $prefix.'х',
315 1
                    self::DAT => $prefix.'м',
316 1
                    self::VINIT => $prefix.'е',
317 1
                    self::TVORIT => $prefix.'ми',
318 1
                    self::PREDLOJ => $prefix.'х',
319
                ];
320
            }
321
322 2
            $suffixes = ['ов', 'ёв', 'ев', 'ин', 'ын'];
323 2
            if ((in_array(S::slice($name, -1), ['е', 'о']) && in_array(S::slice($name, -3, -1), $suffixes)) || in_array(S::slice($name, -2), $suffixes)) {
0 ignored issues
show
Security Bug introduced by
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...
324
                // ово, ёво, ...
325 1
                if (in_array(S::slice($name, -3, -1), $suffixes)) {
0 ignored issues
show
Security Bug introduced by
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...
326
                    $prefix = S::name(S::slice($name, 0, -1));
0 ignored issues
show
Security Bug introduced by
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...
327
                }
328
                // ов, её, ...
329 1
                elseif (in_array(S::slice($name, -2), $suffixes)) {
0 ignored issues
show
Security Bug introduced by
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...
330 1
                    $prefix = S::name($name);
331
                }
332
                return [
333 1
                    self::IMENIT => S::name($name),
334 1
                    self::RODIT => $prefix.'а',
335 1
                    self::DAT => $prefix.'у',
336 1
                    self::VINIT => S::name($name),
337 1
                    self::TVORIT => $prefix.'ым',
338 1
                    self::PREDLOJ => $prefix.'е',
339
                ];
340
            }
341
        }
342
343
        // if no rules matches or name is immutable
344 3
        $name = in_array($name, self::$abbreviations) ? S::upper($name) : S::name($name);
345 3
        return array_fill_keys([self::IMENIT, self::RODIT, self::DAT, self::VINIT, self::TVORIT, self::PREDLOJ], $name);
346
    }
347
348
    /**
349
     * Получение одной формы (падежа) названия.
350
     * @param string $name  Название
351
     * @param integer $case Падеж. Одна из констант \morphos\Russian\Cases или \morphos\Cases.
352
     * @see \morphos\Russian\Cases
353
     * @return string
354
     * @throws \Exception
355
     */
356
    public static function getCase($name, $case)
357
    {
358
        $case = self::canonizeCase($case);
359
        $forms = self::getCases($name);
360
        return $forms[$case];
361
    }
362
}
363