getCurrentEnvironment() public method

Get the current environment if the user is in a project directory.
public getCurrentEnvironment ( Platformsh\Client\Model\Project $expectedProject = null, boolean | null $refresh = null ) : Platformsh\Client\Model\Environment | false
$expectedProject Platformsh\Client\Model\Project The expected project.
$refresh boolean | null Whether to refresh the environments or projects cache.
return Platformsh\Client\Model\Environment | false The current environment.
 /**
  * Get a list of environments IDs that can be checked out.
  *
  * @return string[]
  */
 public function getEnvironmentsForCheckout()
 {
     $project = $this->platformCommand->getCurrentProject();
     if (!$project) {
         return [];
     }
     try {
         $currentEnvironment = $this->platformCommand->getCurrentEnvironment($project);
     } catch (\Exception $e) {
         $currentEnvironment = false;
     }
     $environments = $this->platformCommand->getEnvironments($project, false, false);
     if ($currentEnvironment) {
         $environments = array_filter($environments, function ($environment) use($currentEnvironment) {
             return $environment->id !== $currentEnvironment->id;
         });
     }
     return array_keys($environments);
 }