-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathResourceCaseConverter.php
More file actions
34 lines (27 loc) · 1.01 KB
/
ResourceCaseConverter.php
File metadata and controls
34 lines (27 loc) · 1.01 KB
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
33
34
<?php
declare(strict_types=1);
namespace Symplify\PhpConfigPrinter\CaseConverter;
use PhpParser\Node\Stmt;
use Symplify\PhpConfigPrinter\Contract\CaseConverterInterface;
use Symplify\PhpConfigPrinter\NodeFactory\Service\ServicesPhpNodeFactory;
use Symplify\PhpConfigPrinter\ValueObject\YamlKey;
final readonly class ResourceCaseConverter implements CaseConverterInterface
{
public function __construct(
private ServicesPhpNodeFactory $servicesPhpNodeFactory
) {
}
public function convertToMethodCallStmt(mixed $key, mixed $values): Stmt
{
// Due to the yaml behavior that does not allow the declaration of several identical key names.
if (isset($values['namespace'])) {
$key = $values['namespace'];
unset($values['namespace']);
}
return $this->servicesPhpNodeFactory->createResource($key, $values);
}
public function match(string $rootKey, mixed $key, mixed $values): bool
{
return isset($values[YamlKey::RESOURCE]);
}
}