Skip to content

Commit

Permalink
Switch to new Doctine Inflector API to support versions 1.4 and 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
robgridley committed Oct 13, 2022
1 parent 1727959 commit 065b401
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"ext-fileinfo": "*",
"ext-soap": "*",
"nesbot/carbon": "^1.20 || ^2.0",
"doctrine/inflector": "~1.0"
"doctrine/inflector": "^1.4 || ^2.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
Expand Down
15 changes: 13 additions & 2 deletions src/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pace;

use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory;

class Type
{
Expand Down Expand Up @@ -62,6 +62,13 @@ class Type
'FileAttachment' => 'attachment',
];

/**
* The Doctrine Inflector instance.
*
* @var \Doctrine\Inflector\Inflector|null
*/
protected static $inflector;

/**
* Convert a name to camel case.
*
Expand Down Expand Up @@ -92,7 +99,11 @@ public static function modelify($name)
*/
public static function singularize($name)
{
return Inflector::singularize($name);
if (is_null(static::$inflector)) {
static::$inflector = InflectorFactory::create()->build();
}

return static::$inflector->singularize($name);
}

/**
Expand Down

0 comments on commit 065b401

Please sign in to comment.