Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change of doctrine inflector by symfony string and inflector
- Loading branch information
Showing
9 changed files
with
57 additions
and
61 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Inflector; | ||
|
||
use Doctrine\Common\Inflector\Inflector as LegacyInflector; | ||
use Symfony\Component\Inflector\Inflector as SymfonyInflector; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @deprecated removed in version 3.0 | ||
*/ | ||
final class Inflector | ||
{ | ||
public static function tableize(string $word): string | ||
{ | ||
if (\function_exists('\Symfony\Component\String\u')) { | ||
return (string) \Symfony\Component\String\u($word)->snake(); | ||
} | ||
@trigger_error('This method is deprecated use symfony/string', | ||
E_USER_DEPRECATED); | ||
|
||
return LegacyInflector::tableize($word); | ||
} | ||
|
||
public static function pluralize(string $singular): string | ||
{ | ||
if (class_exists(SymfonyInflector::class)) { | ||
$singularization = SymfonyInflector::singularize($singular); | ||
$pluralization = SymfonyInflector::pluralize(\is_array($singularization) ? end($singularization) : $singularization); | ||
|
||
return \is_array($pluralization) ? end($pluralization) : $pluralization; | ||
} | ||
@trigger_error('This method is deprecated use symfony/string', | ||
E_USER_DEPRECATED); | ||
|
||
return LegacyInflector::pluralize($singular); | ||
} | ||
} |
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
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
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
This file was deleted.
Oops, something went wrong.