Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfbb6d25

Browse files
authored
Merge pull request#29 from MammatusPHP/switch-section-to-enum
Switch section to enum
2 parentsf05fb8a +e490fbe commitfbb6d25

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ the `add` method will be returned through the `get` method and passed directly t
2727
```php
2828
$values = new Values(new Values\Registry(Values\ValuesFile::createFromFile('path/to/helm/chart/values.yaml'));
2929

30-
$values->registry->add('secion', ['PHP_INT_SIZE' => PHP_INT_SIZE]);
30+
$values->registry->add(Section::Deployment, ['PHP_INT_SIZE' => PHP_INT_SIZE]);
3131

32-
$values->registry->get()); // Returns: ['secion' => ['PHP_INT_SIZE' => PHP_INT_SIZE]]
32+
$values->registry->get()); // Returns: ['deployments' => ['PHP_INT_SIZE' => PHP_INT_SIZE]]
3333
```
3434

3535
#License

‎src/Helm/Groups/Section.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespaceMammatus\Kubernetes\Events\Helm\Groups;
6+
7+
enum Section:string
8+
{
9+
case CronJob ='cronjobs';
10+
case Deployment ='deployments';
11+
}

‎src/Helm/Values/Registry.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespaceMammatus\Kubernetes\Events\Helm\Values;
66

7+
useMammatus\Kubernetes\Events\Helm\Groups\Section;
8+
79
finalclass Registry
810
{
911
/** @var array<string, array<string|int, mixed>> */
@@ -14,9 +16,9 @@ public function __construct(private readonly ValuesFile $valuesFile)
1416
}
1517

1618
/** @param array<string|int, mixed> $values */
17-
publicfunctionadd(string$section,array$values):void
19+
publicfunctionadd(Section$section,array$values):void
1820
{
19-
$this->values[$section] =$this->valuesFile->swapInValues($values);
21+
$this->values[$section->value] =$this->valuesFile->swapInValues($values);
2022
}
2123

2224
/** @return array<string, array<string|int, mixed>> */

‎tests/Helm/ValuesTest.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespaceMammatus\Tests\Kubernetes\Events\Helm;
66

7+
useMammatus\Kubernetes\Events\Helm\Groups\Section;
78
useMammatus\Kubernetes\Events\Helm\Values;
89
usePHPUnit\Framework\Attributes\Test;
910
useWyriHaximus\TestUtilities\TestCase;
@@ -18,9 +19,9 @@ public function registry(): void
1819
{
1920
$values =newValues(newValues\Registry(Values\ValuesFile::createFromFile(__DIR__ .DIRECTORY_SEPARATOR .'values.yaml',__DIR__ .DIRECTORY_SEPARATOR .'values-secrets.yaml')));
2021

21-
$values->registry->add('secion', ['PHP_INT_SIZE' =>PHP_INT_SIZE]);
22-
$values->registry->add('fromValues', ['key' =>'${VALUES:nested.value}','foo' =>'${VALUES:env.FOO}']);
22+
$values->registry->add(Section::CronJob, ['PHP_INT_SIZE' =>PHP_INT_SIZE]);
23+
$values->registry->add(Section::Deployment, ['key' =>'${VALUES:nested.value}','foo' =>'${VALUES:env.FOO}']);
2324

24-
self::assertSame(['secion' => ['PHP_INT_SIZE' =>PHP_INT_SIZE],'fromValues' => ['key' =>'bier','foo' =>'bar']],$values->registry->get());
25+
self::assertSame([Section::CronJob->value => ['PHP_INT_SIZE' =>PHP_INT_SIZE],Section::Deployment->value => ['key' =>'bier','foo' =>'bar']],$values->registry->get());
2526
}
2627
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp