Change record status: 
Project: 
Introduced in branch: 
9.5.x
Introduced in version: 
9.5.0
Description: 

New public method \Drupal::getMajorVersion() was added that returns Drupal's major version as a string.

$version = \Drupal::getMajorVersion();
// The value of $version is '9' or '10'.
Impacts: 
Module developers