Skip to content

Commit f120a94

Browse files
committed
fix: suggestions2
1 parent eb4ae25 commit f120a94

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/VCS/Adapter/Git/GitLab.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public function createOrganization(string $orgName): string
6767
]);
6868

6969
$responseBody = $response['body'] ?? [];
70+
$responseHeaders = $response['headers'] ?? [];
71+
$statusCode = $responseHeaders['status-code'] ?? 0;
72+
if ($statusCode >= 400) {
73+
throw new Exception("Creating organization {$orgName} failed with status code {$statusCode}");
74+
}
7075

7176
return ($responseBody['id'] ?? '') . ':' . ($responseBody['path'] ?? '');
7277
}
@@ -87,8 +92,9 @@ private function getOwnerPath(string $owner): string
8792
*/
8893
private function getNamespaceId(string $owner): string
8994
{
90-
if (strstr($owner, ':') !== false) {
91-
return substr($owner, 0, strpos($owner, ':'));
95+
$pos = strpos($owner, ':');
96+
if ($pos !== false) {
97+
return substr($owner, 0, $pos);
9298
}
9399
return $owner;
94100
}

tests/VCS/Adapter/GitLabTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public function setUp(): void
2828

2929
if (empty(static::$accessToken)) {
3030
$this->markTestSkipped('GitLab access token not available');
31-
return;
3231
}
3332

3433
$adapter = new GitLab(new Cache(new None()));

0 commit comments

Comments
 (0)