How to programmatically check whether Magento 2 runs in the developer mode

An example from the core:

A sample detection code:

/** @var \Magento\Framework\App\ObjectManager $om */
$om = \Magento\Framework\App\ObjectManager::getInstance();
/** @return \Magento\Framework\App\State */
$state = $om->get('Magento\Framework\App\State');
/** @var bool $isDeveloperMode */
$isDeveloperMode = \Magento\Framework\App\State::MODE_DEVELOPER === $state->getMode();

See also: