code: public function getCurrentVersion(array $versions)
      {
          if (!empty($versions)) {
              foreach ($versions as $version) {
                  if ($version->active) {
                      return $activeVersion = $version->number;
                  }
              }
          }
  
          throw new LocalizedException(__('Error fetching current version.'));
      }
docs: Fetch current version
  
  @param array $versions
  @return mixed
  @throws LocalizedException