Skip to content

Commit f0c91a4

Browse files
committed
Fix #119: return correct result type in the case of empty structure
1 parent 9d134fb commit f0c91a4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Api/Operator/Site.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ public function delete(string $field, $value): bool
5252
* @param string $field
5353
* @param int|string $value
5454
*
55-
* @return Struct\GeneralInfo
55+
* @return ?Struct\GeneralInfo
5656
*/
57-
public function get(string $field, $value): Struct\GeneralInfo
57+
public function get(string $field, $value): ?Struct\GeneralInfo
5858
{
5959
$items = $this->getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value);
6060

61-
return reset($items);
61+
return reset($items) ?: null;
6262
}
6363

6464
/**

tests/SiteTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ public function testGet()
6868
$this->assertEquals($site->id, $siteInfo->id);
6969

7070
static::$client->site()->delete('id', $site->id);
71+
72+
$siteInfo = static::$client->site()->get('parent-id', static::$webspace->id);
73+
$this->assertNull($siteInfo);
7174
}
7275

7376
public function testGetHostingWoHosting()

0 commit comments

Comments
 (0)