2020 */
2121class Inflector extends DoctrineInflector
2222{
23- /**
24- * The singleton instance.
25- *
26- * @var Inflector
27- * @since 1.0
28- * @deprecated 3.0
29- */
30- private static $ instance ;
31-
3223 /**
3324 * The inflector rules for countability.
3425 *
@@ -90,140 +81,6 @@ public function addCountableRule($data)
9081 return $ this ;
9182 }
9283
93- /**
94- * Adds a specific singular-plural pair for a word.
95- *
96- * @param string $singular The singular form of the word.
97- * @param string $plural The plural form of the word. If omitted, it is assumed the singular and plural are identical.
98- *
99- * @return $this
100- *
101- * @since 1.0
102- * @deprecated 3.0 Use Doctrine\Common\Inflector\Inflector::rules() instead.
103- */
104- public function addWord ($ singular , $ plural = '' )
105- {
106- trigger_deprecation (
107- 'joomla/string ' ,
108- '2.0.0 ' ,
109- '%s() is deprecated and will be removed in 3.0, use %s::rules() instead. ' ,
110- __METHOD__ ,
111- DoctrineInflector::class
112- );
113-
114- if ($ plural !== '' ) {
115- static ::rules (
116- 'plural ' ,
117- [
118- 'irregular ' => [$ plural => $ singular ],
119- ]
120- );
121-
122- static ::rules (
123- 'singular ' ,
124- [
125- 'irregular ' => [$ singular => $ plural ],
126- ]
127- );
128- } else {
129- static ::rules (
130- 'plural ' ,
131- [
132- 'uninflected ' => [$ singular ],
133- ]
134- );
135-
136- static ::rules (
137- 'singular ' ,
138- [
139- 'uninflected ' => [$ singular ],
140- ]
141- );
142- }
143-
144- return $ this ;
145- }
146-
147- /**
148- * Adds a pluralisation rule.
149- *
150- * @param mixed $data A string or an array of regex rules to add.
151- *
152- * @return $this
153- *
154- * @since 1.0
155- * @deprecated 3.0 Use Doctrine\Common\Inflector\Inflector::rules() instead.
156- */
157- public function addPluraliseRule ($ data )
158- {
159- trigger_deprecation (
160- 'joomla/string ' ,
161- '2.0.0 ' ,
162- '%s() is deprecated and will be removed in 3.0, use %s::rules() instead. ' ,
163- __METHOD__ ,
164- DoctrineInflector::class
165- );
166-
167- $ this ->addRule ($ data , 'plural ' );
168-
169- return $ this ;
170- }
171-
172- /**
173- * Adds a singularisation rule.
174- *
175- * @param mixed $data A string or an array of regex rules to add.
176- *
177- * @return $this
178- *
179- * @since 1.0
180- * @deprecated 3.0 Use Doctrine\Common\Inflector\Inflector::rules() instead.
181- */
182- public function addSingulariseRule ($ data )
183- {
184- trigger_deprecation (
185- 'joomla/string ' ,
186- '2.0.0 ' ,
187- '%s() is deprecated and will be removed in 3.0, use %s::rules() instead. ' ,
188- __METHOD__ ,
189- DoctrineInflector::class
190- );
191-
192- $ this ->addRule ($ data , 'singular ' );
193-
194- return $ this ;
195- }
196-
197- /**
198- * Gets an instance of the Inflector singleton.
199- *
200- * @param boolean $new If true (default is false), returns a new instance regardless if one exists. This argument is mainly used for testing.
201- *
202- * @return static
203- *
204- * @since 1.0
205- * @deprecated 3.0 Use static methods without a class instance instead.
206- */
207- public static function getInstance ($ new = false )
208- {
209- trigger_deprecation (
210- 'joomla/string ' ,
211- '2.0.0 ' ,
212- '%s() is deprecated and will be removed in 3.0. ' ,
213- __METHOD__
214- );
215-
216- if ($ new ) {
217- return new static ();
218- }
219-
220- if (!\is_object (self ::$ instance )) {
221- self ::$ instance = new static ();
222- }
223-
224- return self ::$ instance ;
225- }
226-
22784 /**
22885 * Checks if a word is countable.
22986 *
@@ -249,7 +106,7 @@ public function isCountable($word)
249106 */
250107 public function isPlural ($ word )
251108 {
252- return $ this -> toPlural ( $ this -> toSingular ($ word )) === $ word ;
109+ return static :: pluralize ( static :: singularize ($ word )) === $ word ;
253110 }
254111
255112 /**
@@ -263,52 +120,6 @@ public function isPlural($word)
263120 */
264121 public function isSingular ($ word )
265122 {
266- return $ this ->toSingular ($ word ) === $ word ;
267- }
268-
269- /**
270- * Converts a word into its plural form.
271- *
272- * @param string $word The singular word to pluralise.
273- *
274- * @return string The word in plural form.
275- *
276- * @since 1.0
277- * @deprecated 3.0 Use Doctrine\Common\Inflector\Inflector::pluralize() instead.
278- */
279- public function toPlural ($ word )
280- {
281- trigger_deprecation (
282- 'joomla/string ' ,
283- '2.0.0 ' ,
284- '%s() is deprecated and will be removed in 3.0, use %s::pluralize() instead. ' ,
285- __METHOD__ ,
286- DoctrineInflector::class
287- );
288-
289- return static ::pluralize ($ word );
290- }
291-
292- /**
293- * Converts a word into its singular form.
294- *
295- * @param string $word The plural word to singularise.
296- *
297- * @return string The word in singular form.
298- *
299- * @since 1.0
300- * @deprecated 3.0 Use Doctrine\Common\Inflector\Inflector::singularize() instead.
301- */
302- public function toSingular ($ word )
303- {
304- trigger_deprecation (
305- 'joomla/string ' ,
306- '2.0.0 ' ,
307- '%s() is deprecated and will be removed in 3.0, use %s::singularize() instead. ' ,
308- __METHOD__ ,
309- DoctrineInflector::class
310- );
311-
312- return static ::singularize ($ word );
123+ return static ::singularize ($ word ) === $ word ;
313124 }
314125}
0 commit comments