From 722dbd36d07c6efe31ce1ae95e81a09a7dae23fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bouc=CC=8Cek?= Date: Mon, 18 Oct 2021 05:48:29 +0200 Subject: [PATCH] Detector: Add production mode --- src/Detector.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Detector.php b/src/Detector.php index e61a4e5..05873de 100644 --- a/src/Detector.php +++ b/src/Detector.php @@ -102,6 +102,28 @@ public function isDebugMode(?bool $default = false): ?bool return $default; } + /** + * Detect Production mode (opposite to Debug mode) by all method enabled by Detector mode + * Returned value: + * - `false` (force to turn-on debug mode) + * - `true` (force to turn-off debug mode) + * - `null` (unknown/automatic debug mode state) + */ + public function isProductionMode(?bool $default = false): ?bool + { + if (is_bool($default)) { + $default = !$default; + } + + $result = $this->isDebugMode($default); + + if (is_bool($result)) { + $result = !$result; + } + + return $result; + } + /** * Detect Debug mode by `DebugMode\Enabler` helper * Returned value: