-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBuilderExpanderTrait.php
More file actions
32 lines (25 loc) · 935 Bytes
/
BuilderExpanderTrait.php
File metadata and controls
32 lines (25 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
declare(strict_types=1);
namespace Picamator\TransferObject\DefinitionGenerator\Content\Expander;
use Picamator\TransferObject\Generated\DefinitionGeneratorContentTransfer;
trait BuilderExpanderTrait
{
private const string CLASS_NAME_SEPARATOR = '_';
final protected function getClassName(string $propertyName): string
{
$className = ucwords($propertyName, self::CLASS_NAME_SEPARATOR);
return str_replace(self::CLASS_NAME_SEPARATOR, '', $className);
}
/**
* @param array<int|string,mixed> $content
*/
final protected function createGeneratorContentTransfer(
string $className,
array $content,
): DefinitionGeneratorContentTransfer {
return new DefinitionGeneratorContentTransfer([
DefinitionGeneratorContentTransfer::CLASS_NAME => $className,
DefinitionGeneratorContentTransfer::CONTENT => $content,
]);
}
}