* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Adapter\Configuration\CommandHandler; use PrestaShop\PrestaShop\Adapter\Debug\DebugMode; use PrestaShop\PrestaShop\Core\Domain\Configuration\Command\SwitchDebugModeCommand; use PrestaShop\PrestaShop\Core\Domain\Configuration\CommandHandler\SwitchDebugModeHandlerInterface; /** * Handles command that switches debug mode * * @internal */ final class SwitchDebugModeHandler implements SwitchDebugModeHandlerInterface { /** * @var DebugMode */ private $debugMode; /** * @param DebugMode $debugMode */ public function __construct(DebugMode $debugMode) { $this->debugMode = $debugMode; } /** * {@inheritdoc} */ public function handle(SwitchDebugModeCommand $command) { $isDebugModeEnabled = $this->debugMode->isDebugModeEnabled(); if (!$isDebugModeEnabled && $command->enableDebugMode()) { $this->debugMode->enable(); return; } if ($isDebugModeEnabled && !$command->enableDebugMode()) { $this->debugMode->disable(); } } }