Skip to content

Commit 065b401

Browse files
committed
Switch to new Doctine Inflector API to support versions 1.4 and 2.0
1 parent 1727959 commit 065b401

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"ext-fileinfo": "*",
1414
"ext-soap": "*",
1515
"nesbot/carbon": "^1.20 || ^2.0",
16-
"doctrine/inflector": "~1.0"
16+
"doctrine/inflector": "^1.4 || ^2.0"
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": "^8.5",

src/Type.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Pace;
44

5-
use Doctrine\Common\Inflector\Inflector;
5+
use Doctrine\Inflector\InflectorFactory;
66

77
class Type
88
{
@@ -62,6 +62,13 @@ class Type
6262
'FileAttachment' => 'attachment',
6363
];
6464

65+
/**
66+
* The Doctrine Inflector instance.
67+
*
68+
* @var \Doctrine\Inflector\Inflector|null
69+
*/
70+
protected static $inflector;
71+
6572
/**
6673
* Convert a name to camel case.
6774
*
@@ -92,7 +99,11 @@ public static function modelify($name)
9299
*/
93100
public static function singularize($name)
94101
{
95-
return Inflector::singularize($name);
102+
if (is_null(static::$inflector)) {
103+
static::$inflector = InflectorFactory::create()->build();
104+
}
105+
106+
return static::$inflector->singularize($name);
96107
}
97108

98109
/**

0 commit comments

Comments
 (0)