-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replacing icanboogie/inflector with doctrine/inflector because the la…
…tter allows for adjusting rules
- Loading branch information
Showing
4 changed files
with
82 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,41 @@ | ||
<?php | ||
namespace Enobrev; | ||
|
||
use ICanBoogie\Inflector; | ||
use Doctrine\Inflector\InflectorFactory; | ||
use Doctrine\Inflector\Rules\Pattern; | ||
use Doctrine\Inflector\Rules\Patterns; | ||
use Doctrine\Inflector\Rules\Ruleset; | ||
use Doctrine\Inflector\Rules\Substitution; | ||
use Doctrine\Inflector\Rules\Substitutions; | ||
use Doctrine\Inflector\Rules\Transformation; | ||
use Doctrine\Inflector\Rules\Transformations; | ||
use Doctrine\Inflector\Rules\Word; | ||
|
||
|
||
/** | ||
* @param string $sWord | ||
* @return string | ||
*/ | ||
function depluralize(string $sWord) : string { | ||
return Inflector::get()->singularize($sWord); | ||
// https://www.doctrine-project.org/projects/doctrine-inflector/en/2.0/index.html | ||
$oInflector = InflectorFactory::create() | ||
->withSingularRules( | ||
new Ruleset( | ||
new Transformations(), | ||
new Patterns(), | ||
new Substitutions(new Substitution(new Word('data'), new Word('datum'))) | ||
) | ||
) | ||
->build(); | ||
return $oInflector->singularize($sWord); | ||
} | ||
|
||
/** | ||
* @param string $sWord | ||
* @return string | ||
*/ | ||
function pluralize(string $sWord): string { | ||
return Inflector::get()->pluralize($sWord); | ||
// https://www.doctrine-project.org/projects/doctrine-inflector/en/2.0/index.html | ||
$oInflector = InflectorFactory::create()->build(); | ||
return $oInflector->pluralize($sWord); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters