-
-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52923dc
commit 02041b2
Showing
57 changed files
with
2,181 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
namespace Rector\Naming; | ||
|
||
use RectorPrefix202310\Doctrine\Inflector\Inflector; | ||
use RectorPrefix202310\Nette\Utils\Strings; | ||
final class RectorNamingInflector | ||
{ | ||
/** | ||
* @readonly | ||
* @var \Doctrine\Inflector\Inflector | ||
*/ | ||
private $inflector; | ||
/** | ||
* @var string | ||
* @see https://regex101.com/r/VqVvke/3 | ||
*/ | ||
private const DATA_INFO_SUFFIX_REGEX = '#^(?<prefix>.+)(?<suffix>Data|Info)$#'; | ||
public function __construct(Inflector $inflector) | ||
{ | ||
$this->inflector = $inflector; | ||
} | ||
public function singularize(string $name) : string | ||
{ | ||
$matches = Strings::match($name, self::DATA_INFO_SUFFIX_REGEX); | ||
if ($matches === null) { | ||
return $this->inflector->singularize($name); | ||
} | ||
$singularized = $this->inflector->singularize($matches['prefix']); | ||
$uninflectable = $matches['suffix']; | ||
return $singularized . $uninflectable; | ||
} | ||
} |
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
Oops, something went wrong.