TaskErrorHandlerTrait::restoreErrorHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php namespace Comodojo\Extender\Traits;
2
3
use \Comodojo\Foundation\Utils\ErrorLevelConverter;
4
5
/**
6
 * @package     Comodojo Extender
7
 * @author      Marco Giovinazzi <[email protected]>
8
 * @license     MIT
9
 *
10
 * LICENSE:
11
 *
12
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18
 * THE SOFTWARE.
19
 */
20
21
trait TaskErrorHandlerTrait {
22
23
    public function installErrorHandler() {
24
25
        set_error_handler([$this, 'customErrorHandler']);
26
27
    }
28
29
    public function restoreErrorHandler() {
30
31
        restore_error_handler();
32
33
    }
34
35
    public function customErrorHandler($errno, $errstr, $errfile, $errline) {
36
37
        $error = ErrorLevelConverter::convert($errno);
38
39
        $this->getLogger()->error("Unhandled $error ($errno): $errstr [in $errfile line $errline]");
0 ignored issues
show
Bug introduced by
It seems like getLogger() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        $this->/** @scrutinizer ignore-call */ 
40
               getLogger()->error("Unhandled $error ($errno): $errstr [in $errfile line $errline]");
Loading history...
40
41
        return true;
42
43
    }
44
45
}
46