PhealLogger::errorLog()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 11
rs 9.4285
cc 3
eloc 8
nc 3
nop 4
1
<?php
2
/* zKillboard
3
 * Copyright (C) 2012-2015 EVE-KILL Team and EVSCO.
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
class PhealLogger implements \Pheal\Log\CanLog
20
{
21
	private $logID = null;
0 ignored issues
show
Unused Code introduced by
The property $logID is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
22
23
	public function start() {}
24
25
	public function stop() {}
26
27
	public function log($scope,$name,$opts) {
28
		Db::execute("insert into zz_api_log (scope, name, options) values (:scope, :name, :options)",
29
				array(":scope" => $scope, ":name" => $name, ":options" => json_encode($opts)));
30
	}
31
32
	public function errorLog($scope,$name,$opts,$message) {
33
		Db::execute("insert into zz_api_log (scope, name, options, errorCode) values (:scope, :name, :options, :error)",
34
				array(":scope" => $scope, ":name" => $name, ":options" => json_encode($opts), ":error" => substr($message, 0, 127)));
35
		if (Util::startsWith($message, "904:"))
36
		{
37
			global $debug;
38
			Db::execute("replace into zz_storage values ('ApiStop904', date_add(now(), interval 5 minute))");
39
			if ($debug) Log::log("Killing API transactions in this thread: $message");
40
			die();
0 ignored issues
show
Coding Style Compatibility introduced by
The method errorLog() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
41
		}
42
	}
43
}
44