1313
1414namespace Slince \Shopify ;
1515
16- use Doctrine \Common \Inflector \Inflector as LegacyInflector ;
1716use Doctrine \Inflector \InflectorFactory ;
17+ use Doctrine \Inflector \Inflector as DoctrineInflector ;
1818
19- if (class_exists (InflectorFactory::class)) {
20- final class Inflector
19+ final class Inflector
20+ {
21+ /**
22+ * @var DoctrineInflector|null
23+ */
24+ protected static ?DoctrineInflector $ inflector = null ;
25+
26+ protected static function getInflector (): DoctrineInflector
2127 {
22- /**
23- * @var \Doctrine\Inflector\Inflector
24- */
25- protected static $ inflector ;
26-
27- protected static function getInflector (): \Doctrine \Inflector \Inflector
28- {
29- if (null !== Inflector::$ inflector ) {
30- return Inflector::$ inflector ;
31- }
32- return Inflector::$ inflector = InflectorFactory::create ()->build ();
28+ if (null !== Inflector::$ inflector ) {
29+ return Inflector::$ inflector ;
3330 }
31+ return Inflector::$ inflector = InflectorFactory::create ()->build ();
32+ }
3433
35- public static function pluralize (string $ word ): string
36- {
37- return static ::getInflector ()->pluralize ($ word );
38- }
34+ public static function pluralize (string $ word ): string
35+ {
36+ return Inflector ::getInflector ()->pluralize ($ word );
37+ }
3938
40- public static function tableize (string $ word ): string
41- {
42- return static ::getInflector ()->tableize ($ word );
43- }
39+ public static function tableize (string $ word ): string
40+ {
41+ return Inflector ::getInflector ()->tableize ($ word );
42+ }
4443
45- public static function classify (string $ word ): string
46- {
47- return static ::getInflector ()->classify ($ word );
48- }
44+ public static function classify (string $ word ): string
45+ {
46+ return Inflector ::getInflector ()->classify ($ word );
47+ }
4948
5049
51- public static function singularize (string $ word )
52- {
53- return static ::getInflector ()->singularize ($ word );
54- }
55- }
56- } else {
57- final class Inflector extends LegacyInflector
50+ public static function singularize (string $ word )
5851 {
59-
52+ return Inflector:: getInflector ()-> singularize ( $ word );
6053 }
6154}
0 commit comments