1: <?php
2: namespace gregoryv\logger;
3:
4: 5: 6:
7: class State
8: {
9: public $debug = true;
10: public $info = true;
11: public $notice = true;
12: public $warn = true;
13: public $error = true;
14: public $critical = true;
15: public $alert = true;
16: public $emergency = true;
17:
18: 19: 20: 21: 22: 23: 24:
25: public function toggle($flag, $name)
26: {
27: switch ($flag) {
28: case 'on':
29: $onoff = true;
30: break;
31: case 'off':
32: $onoff = false;
33: break;
34:
35: default:
36: throw new \InvalidArgumentException("Flag must be 'on' or 'off'");
37: break;
38: }
39:
40: switch ($name) {
41: case 'debug':
42: $this->debug = $onoff;
43: break;
44: case 'info':
45: $this->info = $onoff;
46: break;
47: case 'notice':
48: $this->notice = $onoff;
49: break;
50: case 'warn':
51: $this->warn = $onoff;
52: break;
53: case 'error':
54: $this->error = $onoff;
55: break;
56: case 'critical':
57: $this->critical = $onoff;
58: break;
59: case 'alert':
60: $this->alert = $onoff;
61: break;
62: case 'emergency':
63: $this->emergency = $onoff;
64: break;
65: default:
66: throw new \InvalidArgumentException("Name must be on (debug|info|notice|warn|error|critical|alert|emergency)");
67: break;
68: }
69: }
70: }
71: