1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: alex |
5
|
|
|
* Date: 9/05/20 |
6
|
|
|
* Time: 4:00 AM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace POData; |
10
|
|
|
|
11
|
|
|
use AlgoWeb\ODataMetadata\MetadataManager; |
12
|
|
|
use Doctrine\Inflector\Inflector; |
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class Pluralizer - hoisted from Laravel to support StringUtility |
16
|
|
|
* @package POData |
17
|
|
|
*/ |
18
|
|
|
class Pluralizer |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Uncountable word forms. |
22
|
|
|
* |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
public static $uncountable = [ |
26
|
|
|
'audio', |
27
|
|
|
'bison', |
28
|
|
|
'cattle', |
29
|
|
|
'chassis', |
30
|
|
|
'compensation', |
31
|
|
|
'coreopsis', |
32
|
|
|
'data', |
33
|
|
|
'deer', |
34
|
|
|
'education', |
35
|
|
|
'emoji', |
36
|
|
|
'equipment', |
37
|
|
|
'evidence', |
38
|
|
|
'feedback', |
39
|
|
|
'firmware', |
40
|
|
|
'fish', |
41
|
|
|
'furniture', |
42
|
|
|
'gold', |
43
|
|
|
'hardware', |
44
|
|
|
'information', |
45
|
|
|
'jedi', |
46
|
|
|
'kin', |
47
|
|
|
'knowledge', |
48
|
|
|
'love', |
49
|
|
|
'metadata', |
50
|
|
|
'money', |
51
|
|
|
'moose', |
52
|
|
|
'news', |
53
|
|
|
'nutrition', |
54
|
|
|
'offspring', |
55
|
|
|
'plankton', |
56
|
|
|
'pokemon', |
57
|
|
|
'police', |
58
|
|
|
'rain', |
59
|
|
|
'recommended', |
60
|
|
|
'related', |
61
|
|
|
'rice', |
62
|
|
|
'series', |
63
|
|
|
'sheep', |
64
|
|
|
'software', |
65
|
|
|
'species', |
66
|
|
|
'swine', |
67
|
|
|
'traffic', |
68
|
|
|
'wheat', |
69
|
|
|
]; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Get the plural form of an English word. |
73
|
|
|
* |
74
|
|
|
* @param string $value |
75
|
|
|
* @param int $count |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
|
|
public static function plural($value, $count = 2) |
79
|
|
|
{ |
80
|
|
|
if ((int) abs($count) === 1 || static::uncountable($value)) { |
81
|
|
|
return $value; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$plural = MetadataManager::pluralize($value); |
85
|
|
|
|
86
|
|
|
return static::matchCase($plural, $value); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get the singular form of an English word. |
91
|
|
|
* |
92
|
|
|
* @param string $value |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
public static function singular($value) |
96
|
|
|
{ |
97
|
|
|
$singular = Inflector::singularize($value); |
98
|
|
|
|
99
|
|
|
return static::matchCase($singular, $value); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Determine if the given value is uncountable. |
104
|
|
|
* |
105
|
|
|
* @param string $value |
106
|
|
|
* @return bool |
107
|
|
|
*/ |
108
|
|
|
protected static function uncountable($value) |
109
|
|
|
{ |
110
|
|
|
return in_array(strtolower($value), static::$uncountable); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Attempt to match the case on two strings. |
115
|
|
|
* |
116
|
|
|
* @param string $value |
117
|
|
|
* @param string $comparison |
118
|
|
|
* @return string |
119
|
|
|
*/ |
120
|
|
|
protected static function matchCase($value, $comparison) |
121
|
|
|
{ |
122
|
|
|
$functions = ['mb_strtolower', 'mb_strtoupper', 'ucfirst', 'ucwords']; |
123
|
|
|
|
124
|
|
|
foreach ($functions as $function) { |
125
|
|
|
if (call_user_func($function, $comparison) === $comparison) { |
126
|
|
|
return call_user_func($function, $value); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
return $value; |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths