Skip to content

Commit 605afe2

Browse files
committed
Applied suggestion
1 parent de74445 commit 605afe2

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

src/Adapter/Composer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ public function addGitlabTokenAuthentication(string $token, string $url = 'gitla
243243
);
244244
}
245245

246-
public function addGithubOauthAuthentication(string $token): void
246+
public function addGithubOauthAuthentication(string $token, string $url = 'github.com'): void
247247
{
248248
$this->command(
249249
'composer',
250250
'config',
251251
'--auth',
252-
'github-oauth.github.com',
252+
sprintf('github-oauth.%s', $url),
253253
$token
254254
);
255255
}

src/Adapter/Docker/SatelliteBuilder.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ public function withGithubOauthAuthentication(string $token, string $domain = 'g
136136
{
137137
$this->authenticationTokens[$domain] = [
138138
'type' => 'github-token',
139-
'url' => $domain,
140139
'token' => $token,
141140
];
142141

@@ -147,7 +146,6 @@ public function withGitlabOauthAuthentication(string $token, string $domain = 'g
147146
{
148147
$this->authenticationTokens[$domain] = [
149148
'type' => 'gitlab-oauth',
150-
'url' => $domain,
151149
'token' => $token,
152150
];
153151

@@ -158,7 +156,6 @@ public function withGitlabTokenAuthentication(string $token, string $domain = 'g
158156
{
159157
$this->authenticationTokens[$domain] = [
160158
'type' => 'gitlab-token',
161-
'url' => $domain,
162159
'token' => $token,
163160
];
164161

@@ -257,9 +254,9 @@ public function build(): Configurator\SatelliteInterface
257254
if (\count($this->authenticationTokens) > 0) {
258255
foreach ($this->authenticationTokens as $url => $authentication) {
259256
match ($authentication['type']) {
260-
'gitlab-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabOauthAuthentication($authentication['token'])),
261-
'gitlab-token' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabTokenAuthentication($authentication['token'])),
262-
'github-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGithubOauthAuthentication($authentication['token'])),
257+
'gitlab-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabOauthAuthentication($authentication['token'], $authentication['url'])),
258+
'gitlab-token' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabTokenAuthentication($authentication['token'], $authentication['url'])),
259+
'github-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGithubOauthAuthentication($authentication['token'], $authentication['url'])),
263260
'http-basic' => $dockerfile->push(new Dockerfile\PHP\ComposerHttpBasicAuthentication($url, $authentication['username'], $authentication['password'])),
264261
'http-bearer' => $dockerfile->push(new Dockerfile\PHP\ComposerHttpBearerAuthentication($url, $authentication['token'])),
265262
default => new \LogicException(),

src/Adapter/Filesystem/SatelliteBuilder.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ final class SatelliteBuilder implements Configurator\SatelliteBuilderInterface
2020
];
2121
private array $authenticationTokens = [];
2222
private array $repositories = [];
23-
private null|PackagingContract\AssetInterface|PackagingContract\FileInterface $composerJsonFile = null;
24-
private null|PackagingContract\AssetInterface|PackagingContract\FileInterface $composerLockFile = null;
23+
private PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerJsonFile = null;
24+
private PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerLockFile = null;
2525
/** @var iterable<array<string, string>> */
2626
private iterable $paths = [];
2727
/** @var \AppendIterator<string,PackagingContract\FileInterface, \Iterator<string,PackagingContract\FileInterface>> */
@@ -55,7 +55,7 @@ public function withComposerRequire(string ...$package): self
5555

5656
public function withComposerFile(
5757
PackagingContract\AssetInterface|PackagingContract\FileInterface $composerJsonFile,
58-
PackagingContract\AssetInterface|PackagingContract\FileInterface $composerLockFile = null
58+
PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerLockFile = null
5959
): self {
6060
$this->composerJsonFile = $composerJsonFile;
6161
$this->composerLockFile = $composerLockFile;
@@ -65,7 +65,7 @@ public function withComposerFile(
6565

6666
public function withFile(
6767
PackagingContract\AssetInterface|PackagingContract\FileInterface $source,
68-
string $destinationPath = null
68+
?string $destinationPath = null
6969
): self {
7070
if (!$source instanceof PackagingContract\FileInterface) {
7171
$source = new Packaging\VirtualFile($source);
@@ -80,7 +80,7 @@ public function withFile(
8080
return $this;
8181
}
8282

83-
public function withDirectory(PackagingContract\DirectoryInterface $source, string $destinationPath = null): self
83+
public function withDirectory(PackagingContract\DirectoryInterface $source, ?string $destinationPath = null): self
8484
{
8585
$this->paths[] = [$source->getPath(), $destinationPath ?? $source->getPath()];
8686

@@ -110,7 +110,6 @@ public function withGitlabOauthAuthentication(string $token, string $domain = 'g
110110
{
111111
$this->authenticationTokens[$domain] = [
112112
'type' => 'gitlab-oauth',
113-
'url' => $domain,
114113
'token' => $token,
115114
];
116115

@@ -121,7 +120,6 @@ public function withGitlabTokenAuthentication(string $token, string $domain = 'g
121120
{
122121
$this->authenticationTokens[$domain] = [
123122
'type' => 'gitlab-token',
124-
'url' => $domain,
125123
'token' => $token,
126124
];
127125

@@ -132,7 +130,6 @@ public function withGithubOauthAuthentication(string $token, string $domain = 'g
132130
{
133131
$this->authenticationTokens[$domain] = [
134132
'type' => 'github-oauth',
135-
'url' => $domain,
136133
'token' => $token,
137134
];
138135

@@ -143,7 +140,6 @@ public function withHttpBasicAuthentication(string $domain, string $username, st
143140
{
144141
$this->authenticationTokens[$domain] = [
145142
'type' => 'http-basic',
146-
'url' => $domain,
147143
'username' => $username,
148144
'password' => $password,
149145
];
@@ -155,7 +151,6 @@ public function withHttpBearerAuthentication(string $domain, string $token): sel
155151
{
156152
$this->authenticationTokens[$domain] = [
157153
'type' => 'http-basic',
158-
'url' => $domain,
159154
'token' => $token,
160155
];
161156

@@ -211,10 +206,10 @@ public function build(): Configurator\SatelliteInterface
211206
if (\count($this->authenticationTokens) > 0) {
212207
foreach ($this->authenticationTokens as $url => $authentication) {
213208
match ($authentication['type']) {
214-
'gitlab-oauth' => $composer->addGitlabOauthAuthentication($authentication['token']),
215-
'gitlab-token' => $composer->addGitlabTokenAuthentication($authentication['token']),
216-
'github-oauth' => $composer->addGithubOauthAuthentication($authentication['token']),
217-
'http-basic' => $composer->addHttpBasicAuthentication($url, $authentication['username'], $authentication['password']),
209+
'gitlab-oauth' => $composer->addGitlabOauthAuthentication($authentication['token'], $url),
210+
'gitlab-token' => $composer->addGitlabTokenAuthentication($authentication['token'], $url),
211+
'github-oauth' => $composer->addGithubOauthAuthentication($authentication['token'], $url),
212+
'http-basic' => $composer->addHttpBasicAuthentication($url, $authentication['username'], $url),
218213
'http-bearer' => $composer->addHttpBearerAuthentication($url, $authentication['token']),
219214
default => $composer->addAuthenticationToken($url, $authentication['token']),
220215
};

0 commit comments

Comments
 (0)