minor improvement

This commit is contained in:
Dr Masroor Ehsan 2025-01-23 10:25:25 +06:00
parent a64959b2d0
commit b3ceda84b8

View File

@ -33,16 +33,26 @@ public function getServerStatistics(): array
return json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR); return json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
} }
private static function studyPath(string $study_id, ?string $sub = null): string
{
$parts = ['studies', ltrim($study_id, '/')];
if (filled($sub)) {
$parts[] = ltrim($sub, '/');
}
return implode('/', $parts);
}
public function getStudySeries(string $study_id): array public function getStudySeries(string $study_id): array
{ {
$response = $this->getClient()->get('/studies/' . $study_id . '/series?expand'); $response = $this->getClient()->get(self::studyPath($study_id, 'series?expand'));
return json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR); return json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
} }
public function getStudyInstances(string $study_id): array public function getStudyInstances(string $study_id): array
{ {
$response = $this->getClient()->get('/studies/' . $study_id . '/instances?expand'); $response = $this->getClient()->get(self::studyPath($study_id, 'instances?expand'));
return json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR); return json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
} }