Code Duplication    Length = 15-15 lines in 2 locations

src/MetadataManager.php 1 location

@@ 99-113 (lines=15) @@
96
     * form from singular if not provided
97
     * @return string Pluralized word if quantity is not one, otherwise singular
98
     */
99
    public static function pluralize($quantity, $singular, $plural = null)
100
    {
101
        if ($quantity == 1 || !strlen($singular)) {
102
            return $singular;
103
        }
104
        if ($plural !== null) {
105
            return $plural;
106
        }
107
108
        $last_letter = strtolower($singular[strlen($singular) - 1]);
109
        switch ($last_letter) {
110
            case 'y':
111
                return substr($singular, 0, -1) . 'ies';
112
            case 's':
113
                return $singular . 'es';
114
            default:
115
                return $singular . 's';
116
        }

tests/EdmxTest.php 1 location

@@ 247-261 (lines=15) @@
244
     * @param string $plural Plural form of word; function will attempt to deduce plural form from singular if not provided
245
     * @return string Pluralized word if quantity is not one, otherwise singular
246
     */
247
    public static function pluralize($quantity, $singular, $plural = null)
248
    {
249
        if ($quantity == 1 || !strlen($singular)) {
250
            return $singular;
251
        }
252
        if ($plural !== null) {
253
            return $plural;
254
        }
255
256
        $last_letter = strtolower($singular[strlen($singular) - 1]);
257
        switch ($last_letter) {
258
            case 'y':
259
                return substr($singular, 0, -1) . 'ies';
260
            case 's':
261
                return $singular . 'es';
262
            default:
263
                return $singular . 's';
264
        }