Skip to content

Commit

Permalink
replacement is now based on word and not whole table name (#11)
Browse files Browse the repository at this point in the history
* replacement is now based on word and not whole table name
  • Loading branch information
dakorpar committed Mar 13, 2019
1 parent dfc37d6 commit ad5546f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Heimkaup ruleset">
<ruleset name="ruleset">
<rule ref="./vendor/ninjify/coding-standard/ruleset.xml">
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration"/>
<exclude name="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment" />
Expand Down
5 changes: 1 addition & 4 deletions src/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ public function generateEntity(string $table): void

protected function getClassName(string $table): string
{
if (isset($this->config->replacements[$table])) {
return $this->config->replacements[$table];
}
return $this->config->prefix . Helper::camelize($table) . $this->config->suffix;
return $this->config->prefix . Helper::camelize($table, $this->config->replacements) . $this->config->suffix;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Generator/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public static function multiArrayFlip(array $array): array
return $result;
}

public static function camelize(string $input, string $separator = '_'): string
public static function camelize(string $input, array $replacements = [], string $separator = '_'): string
{
$words = explode($separator, $input);
$result = '';
foreach ($words as $word) {
$result .= Inflector::singularize(ucfirst($word));
$result .= $replacements[$word] ?? Inflector::singularize(ucfirst($word));
}
return $result;
}
Expand Down

0 comments on commit ad5546f

Please sign in to comment.