Skip to content

Commit 722dbd3

Browse files
committed
Detector: Add production mode
1 parent 987d1bb commit 722dbd3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Detector.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,28 @@ public function isDebugMode(?bool $default = false): ?bool
102102
return $default;
103103
}
104104

105+
/**
106+
* Detect Production mode (opposite to Debug mode) by all method enabled by Detector mode
107+
* Returned value:
108+
* - `false` (force to turn-on debug mode)
109+
* - `true` (force to turn-off debug mode)
110+
* - `null` (unknown/automatic debug mode state)
111+
*/
112+
public function isProductionMode(?bool $default = false): ?bool
113+
{
114+
if (is_bool($default)) {
115+
$default = !$default;
116+
}
117+
118+
$result = $this->isDebugMode($default);
119+
120+
if (is_bool($result)) {
121+
$result = !$result;
122+
}
123+
124+
return $result;
125+
}
126+
105127
/**
106128
* Detect Debug mode by `DebugMode\Enabler` helper
107129
* Returned value:

0 commit comments

Comments
 (0)