PicoErrorResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 17
dl 0
loc 33
c 0
b 0
f 0
ccs 0
cts 19
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 22 2
1
<?php
2
/**
3
 * CMS Pico - Create websites using Pico CMS for Nextcloud.
4
 *
5
 * @copyright Copyright (c) 2019, Daniel Rudolf (<[email protected]>)
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 * This program is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License as
11
 * published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
declare(strict_types=1);
24
25
namespace OCA\CMSPico\Http;
26
27
use OCA\CMSPico\AppInfo\Application;
28
use OCP\AppFramework\Http;
29
use OCP\AppFramework\Http\TemplateResponse;
30
31
class PicoErrorResponse extends TemplateResponse
32
{
33
	/** @var \Exception|null */
34
	private $exception;
35
36
	/**
37
	 * PicoErrorResponse constructor.
38
	 *
39
	 * @param string|null $message
40
	 * @param \Exception|null $exception
41
	 */
42
	public function __construct(string $message = null, \Exception $exception = null)
43
	{
44
		$this->exception = $exception;
45
46
		$params = [
47
			'message' => $message,
48
			'debugMode' => \OC::$server->getSystemConfig()->getValue('debug', false),
0 ignored issues
show
Deprecated Code introduced by
The function OC\Server::getSystemConfig() has been deprecated: 20.0.0 ( Ignorable by Annotation )

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

48
			'debugMode' => /** @scrutinizer ignore-deprecated */ \OC::$server->getSystemConfig()->getValue('debug', false),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
49
			'remoteAddr' => \OC::$server->getRequest()->getRemoteAddress(),
0 ignored issues
show
Deprecated Code introduced by
The function OC\Server::getRequest() has been deprecated: 20.0.0 ( Ignorable by Annotation )

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

49
			'remoteAddr' => /** @scrutinizer ignore-deprecated */ \OC::$server->getRequest()->getRemoteAddress(),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
50
			'requestID' => \OC::$server->getRequest()->getId(),
0 ignored issues
show
Deprecated Code introduced by
The function OC\Server::getRequest() has been deprecated: 20.0.0 ( Ignorable by Annotation )

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

50
			'requestID' => /** @scrutinizer ignore-deprecated */ \OC::$server->getRequest()->getId(),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
51
		];
52
53
		if ($this->exception !== null) {
54
			$params['errorClass'] = get_class($this->exception);
55
			$params['errorMsg'] = $this->exception->getMessage();
56
			$params['errorCode'] = $this->exception->getCode();
57
			$params['errorFile'] = $this->exception->getFile();
58
			$params['errorLine'] = $this->exception->getLine();
59
			$params['errorTrace'] = $this->exception->getTraceAsString();
60
		}
61
62
		parent::__construct(Application::APP_NAME, 'error', $params, 'guest');
63
		$this->setStatus(Http::STATUS_INTERNAL_SERVER_ERROR);
64
	}
65
}
66