Skip to content

Commit 82fc88a

Browse files
committed
Adding API endpoints to interact with custom properties
1 parent dcd8ded commit 82fc88a

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

lib/Github/Api/Repository/CustomProperties.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,29 @@
1313
class CustomProperties extends AbstractApi
1414
{
1515
/**
16-
* @param string $owner The account owner of the repository.
16+
* @param string $owner The account owner of the repository.
1717
* @param string $repository The name of the repository.
1818
* @return array|string
1919
*/
2020
public function all(string $owner, string $repository)
2121
{
22-
return $this->get('/repos/' . rawurlencode($owner) . '/' . rawurlencode($repository) . '/properties/values');
22+
return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/properties/values');
2323
}
2424

2525
/**
26-
* @param string $owner The account owner of the repository.
27-
* @param string $repository The name of the repository.
26+
* @param string $owner The account owner of the repository.
27+
* @param string $repository The name of the repository.
2828
* @param string $propertyName The name of the property to retrieve.
29-
* @return array
29+
*
3030
* @throws RuntimeException if the property is not found.
31+
*
32+
* @return array
3133
*/
3234
public function show(string $owner, string $repository, string $propertyName): array
3335
{
3436
$allProperties = $this->all($owner, $repository);
3537

36-
if(!is_array($allProperties)) {
38+
if (!is_array($allProperties)) {
3739
throw new RuntimeException('Unexpected response from GitHub API.');
3840
}
3941

@@ -47,13 +49,13 @@ public function show(string $owner, string $repository, string $propertyName): a
4749
}
4850

4951
/**
50-
* @param string $owner The account owner of the repository.
51-
* @param string $repository The name of the repository.
52+
* @param string $owner The account owner of the repository.
53+
* @param string $repository The name of the repository.
5254
* @param array<string, mixed> $params
5355
* @return array|string
5456
*/
5557
public function update(string $owner, string $repository, array $params)
5658
{
57-
return $this->patch('/repos/' . rawurlencode($owner) . '/' . rawurlencode($repository) . '/properties/values', $params);
59+
return $this->patch('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/properties/values', $params);
5860
}
5961
}

test/Github/Tests/Api/Repository/CustomPropertiesTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ public function testShowPropertyExists()
3333
->with('/repos/owner/repo/properties/values')
3434
->willReturn($allProperties);
3535

36-
$expectedResult = ['property_name' =>'property2', 'value' => 'value2'];
36+
$expectedResult = [
37+
'property_name' => 'property2',
38+
'value' => 'value2'
39+
];
40+
3741
$this->assertEquals($expectedResult, $api->show('owner', 'repo', 'property2'));
3842
}
3943

@@ -51,7 +55,7 @@ public function testShowPropertyDoesNotExist()
5155
->willReturn($allProperties);
5256

5357
$this->expectException(\RuntimeException::class);
54-
$this->expectExceptionMessage("Property [property3] not found.");
58+
$this->expectExceptionMessage('Property [property3] not found.');
5559

5660
$api->show('owner', 'repo', 'property3');
5761
}

0 commit comments

Comments
 (0)