1: <?php
2: /**
3: * LICENSE (BSD)
4: *
5: * Copyright (c) 2012, Gerd Christian Kunze
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions are
10: * met:
11: *
12: * * Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: *
15: * * Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: *
19: * * Neither the name of Gerd Christian Kunze nor the names of the
20: * contributors may be used to endorse or promote products derived from
21: * this software without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24: * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34: *
35: * Factory
36: * 31.07.2012 18:09
37: */
38: namespace MOC\Core\Error;
39: use MOC\Api;
40: use MOC\Generic\Common;
41:
42: /**
43: *
44: */
45: class Reporting implements Common {
46: /** @var Reporting $Singleton */
47: private static $Singleton = null;
48:
49: /**
50: * Get Singleton/Instance
51: *
52: * @static
53: * @return Reporting
54: */
55: public static function InterfaceInstance() {
56: if( self::$Singleton === null ) {
57: self::$Singleton = new Reporting();
58: } return self::$Singleton;
59: }
60:
61: /**
62: * Get Dependencies
63: *
64: * @static
65: * @return \MOC\Core\Depending
66: */
67: public static function InterfaceDepending() {
68: return Api::Core()->Depending();
69: }
70:
71: /**
72: * Get Changelog
73: *
74: * @static
75: * @return \MOC\Core\Changelog
76: */
77: public static function InterfaceChangelog() {
78: return Api::Core()->Changelog()->Create( __CLASS__ );
79: }
80:
81: /** @var int $Level */
82: public static $Level = E_ALL;
83: /** @var bool $Display */
84: public static $Display = true;
85: /** @var bool $Debug */
86: public static $Debug = true;
87:
88: /**
89: * Apply settings
90: */
91: public function Apply() {
92: /**
93: * Set Level
94: */
95: error_reporting( self::$Level );
96: /**
97: * Disable PHP-Error-Display
98: */
99: if( self::$Debug ) {
100: ini_set('display_errors',1);
101: } else {
102: ini_set('display_errors',0);
103: }
104: /**
105: * Disable xDebug
106: */
107: if( function_exists( 'xdebug_disable' ) ) {
108: xdebug_disable();
109: }
110: }
111:
112: /**
113: * @param int $E_LEVEL
114: *
115: * @return Reporting
116: */
117: public function Level( $E_LEVEL = null ) {
118: if( null !== $E_LEVEL ) {
119: self::$Level = $E_LEVEL;
120: } return $this;
121: }
122:
123: /**
124: * @param bool $Toggle
125: *
126: * @return Reporting
127: */
128: public function Display( $Toggle = null ) {
129: if( null !== $Toggle ) {
130: self::$Display = $Toggle;
131: } return $this;
132: }
133:
134: /**
135: * @param bool $Toggle
136: *
137: * @return Reporting
138: */
139: public function Debug( $Toggle = null ) {
140: if( null !== $Toggle ) {
141: self::$Debug = $Toggle;
142: } return $this;
143: }
144:
145: }
146: