Skip to content

Commit

Permalink
Clarify getCurrentDeployment type
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 18, 2024
1 parent 75c2483 commit 487dd34
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/Service/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1246,15 +1246,8 @@ public function getExternalHttpClient(): ClientInterface

/**
* Get the current deployment for an environment.
*
* @param Environment $environment
* @param bool $refresh
* @param bool $required
*
* @return EnvironmentDeployment|false
* The current deployment, or false if $required is false and there is no current deployment.
*/
public function getCurrentDeployment(Environment $environment, bool $refresh = false, bool $required = true): EnvironmentDeployment|false
public function getCurrentDeployment(Environment $environment, bool $refresh = false): EnvironmentDeployment
{
$cacheKey = implode(':', ['current-deployment', $environment->project, $environment->id, $environment->head_commit]);
if (!$refresh && isset(self::$deploymentsCache[$cacheKey])) {
Expand All @@ -1263,16 +1256,14 @@ public function getCurrentDeployment(Environment $environment, bool $refresh = f
$data = $this->cache->fetch($cacheKey);
if ($data === false || $refresh) {
try {
$deployment = $environment->getCurrentDeployment($required);
/** @var EnvironmentDeployment $deployment */
$deployment = $environment->getCurrentDeployment();
} catch (EnvironmentStateException $e) {
if ($e->getEnvironment()->status === 'inactive') {
throw new EnvironmentStateException('The environment is inactive', $e->getEnvironment());
}
throw $e;
}
if (!$required && $deployment === false) {
return self::$deploymentsCache[$cacheKey] = false;
}
$data = $deployment->getData();
$data['_uri'] = $deployment->getUri();
$this->cache->save($cacheKey, $data);
Expand Down

0 comments on commit 487dd34

Please sign in to comment.