Skip to content

Commit 1906046

Browse files
refactor(Command): modify and refactor CreatorEnum
1 parent c6adf75 commit 1906046

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Creators/CreatorEnum.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Eghamat24\DatabaseRepository\Creators;
44

55
use Illuminate\Support\Collection;
6-
use Eghamat24\DatabaseRepository\Commands\MakeEnum;
76

87
class CreatorEnum implements IClassCreator
98
{
@@ -22,12 +21,14 @@ public function createAttributes(): array
2221
{
2322
$attributes = [];
2423
foreach ($this->enum as $_enum) {
24+
2525
$attributes[strtoupper($_enum)] = $this->writeAttribute(
2626
$this->attributeStub,
2727
strtoupper($_enum),
2828
$_enum
2929
);
3030
}
31+
3132
return $attributes;
3233
}
3334

@@ -58,8 +59,11 @@ public function getClassName(): string
5859

5960
private function writeAttribute(string $attributeStub, string $attributeName, string $attributeString): string
6061
{
61-
return str_replace(['{{ AttributeName }}', '{{ AttributeString }}'],
62-
[$attributeName, $attributeString],
63-
$attributeStub);
62+
$replaceMapping = [
63+
'{{ AttributeName }}' => $attributeName,
64+
'{{ AttributeString }}' => $attributeString,
65+
];
66+
67+
return str_replace(array_keys($replaceMapping), array_values($replaceMapping), $attributeStub);
6468
}
6569
}

0 commit comments

Comments
 (0)