Skip to content

Commit 1f79570

Browse files
author
Bastian Schwarz
committed
Added basic classes and interface
1 parent 376a672 commit 1f79570

16 files changed

Lines changed: 267 additions & 4 deletions

.idea/php-test-framework.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/All.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"psalm": "tools/psalm --threads=10 --long-progress",
3535
"composer-unused": "tools/composer-unused --no-progress --no-interaction",
3636
"composer-require-checker": "tools/composer-require-checker --no-interaction",
37-
"infection": "XDEBUG_MODE=coverage tools/infection --min-msi=95 --min-covered-msi=95 --threads=4 --no-progress --show-mutations",
37+
"infection": "XDEBUG_MODE=coverage tools/infection --min-msi=100 --min-covered-msi=100 --no-progress --show-mutations",
3838
"ci-all": [
3939
"@phpunit",
4040
"@psalm",

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
2424
cacheDirectory=".cache/psalm"
2525
findUnusedBaselineEntry="true"
26-
findUnusedCode="true"
26+
findUnusedCode="false"
2727
>
2828
<projectFiles>
2929
<directory name="src"/>

src/Client/ClientInterface.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace de\codenamephp\deployer\secrets\base\Client;
4+
5+
use de\codenamephp\deployer\secrets\base\Secret\Payload\PayloadInterface;
6+
use de\codenamephp\deployer\secrets\base\Secret\SecretInterface;
7+
8+
/**
9+
* Interface for a common client that fetches payloads (since the payload is what we care about here)
10+
*/
11+
interface ClientInterface {
12+
13+
/**
14+
* Sends a request to the Secret Manager to fetch the payload of a secret
15+
*
16+
* @param SecretInterface $secret The secret of the payload
17+
* @return PayloadInterface
18+
*/
19+
public function fetchPayload(SecretInterface $secret) : PayloadInterface;
20+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace de\codenamephp\deployer\secrets\base\Secret\Payload\Factory;
4+
5+
use de\codenamephp\deployer\secrets\base\Secret\Payload\PayloadInterface;
6+
7+
interface FactoryInterface {
8+
9+
public function build(string $content): PayloadInterface;
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace de\codenamephp\deployer\secrets\base\Secret\Payload\Factory;
4+
5+
use de\codenamephp\deployer\secrets\base\Secret\Payload\PayloadInterface;
6+
7+
final class Sealed implements FactoryInterface {
8+
9+
public function build(string $content) : PayloadInterface {
10+
return new \de\codenamephp\deployer\secrets\base\Secret\Payload\Sealed($content);
11+
}
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace de\codenamephp\deployer\secrets\base\Secret\Payload;
4+
5+
/**
6+
* Interface for a payload of a secret. Contains the content as string and checksums
7+
*/
8+
interface PayloadInterface {
9+
10+
/**
11+
* Gets the secret payload as string (so the thing you actually want to use)
12+
*
13+
* @return string
14+
*/
15+
public function getContent() : string;
16+
}

src/Secret/Payload/Sealed.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace de\codenamephp\deployer\secrets\base\Secret\Payload;
4+
5+
/**
6+
* Read-only class for a sealed secret payload
7+
*/
8+
final class Sealed implements PayloadInterface {
9+
10+
public function __construct(public readonly string $content) {}
11+
12+
public function getContent() : string {
13+
return $this->content;
14+
}
15+
}

0 commit comments

Comments
 (0)