Passed
Branch master (f497d2)
by Mike
03:18
created

GSyncException   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 30
rs 10
c 1
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A showLegalNotice() 0 2 1
A __construct() 0 11 3
A getHTTPHeaders() 0 2 1
A getHTTPCodeString() 0 2 1
1
<?php
2
/*
3
 * SPDX-License-Identifier: AGPL-3.0-only
4
 * SPDX-FileCopyrightText: Copyright 2007-2016 Zarafa Deutschland GmbH
5
 * SPDX-FileCopyrightText: Copyright 2020-2022 grommunio GmbH
6
 *
7
 * Main grommunio-sync exception
8
 */
9
10
class GSyncException extends Exception {
11
	protected $defaultLogLevel = LOGLEVEL_FATAL;
12
	protected $httpReturnCode = HTTP_CODE_500;
13
	protected $httpReturnMessage = "Internal Server Error";
14
	protected $httpHeaders = [];
15
	protected $showLegal = true;
16
17
	public function __construct($message = "", $code = 0, $previous = null, $logLevel = false) {
18
		if (!$message) {
19
			$message = $this->httpReturnMessage;
20
		}
21
22
		if (!$logLevel) {
23
			$logLevel = $this->defaultLogLevel;
24
		}
25
26
		parent::__construct($message, (int) $code);
27
		SLog::Write($logLevel, get_class($this) . ': ' . $message . ' - code: ' . $code . ' - file: ' . $this->getFile() . ':' . $this->getLine(), false);
28
	}
29
30
	public function getHTTPCodeString() {
31
		return $this->httpReturnCode . " " . $this->httpReturnMessage;
32
	}
33
34
	public function getHTTPHeaders() {
35
		return $this->httpHeaders;
36
	}
37
38
	public function showLegalNotice() {
39
		return $this->showLegal;
40
	}
41
}
42