Killmail   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 8
lcom 0
cbo 2
dl 0
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 8 2
B getCrestHash() 0 25 6
1
<?php
2
3
class Killmail
4
{
5
	public static function get($killID)
6
	{
7
		$kill = Db::queryField("select kill_json from zz_killmails where killID = :killID", "kill_json", array(":killID" => $killID));
8
		if ($kill != '') {
9
			Cache::set("Kill$killID", $kill);
10
			return $kill;
11
		}
12
	}
13
14
	// https://forums.eveonline.com/default.aspx?g=posts&m=4900335#post4900335
15
	public static function getCrestHash($killID)
16
	{
17
		$killmail = json_decode(Killmail::get($killID), true);
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
18
19
		$victim = $killmail["victim"];
20
		$victimID = $victim["characterID"] == 0 ? "None" : $victim["characterID"];
21
22
		$attackers = $killmail["attackers"];
23
		$attacker = null;
24
		foreach($attackers as $att)
25
		{
26
			if ($att["finalBlow"] != 0) $attacker = $att;
27
		}
28
		if ($attacker == null) $attacker = $attackers[0];
29
		$attackerID = $attacker["characterID"] == 0 ? "None" : $attacker["characterID"];
30
31
		$shipTypeID = $victim["shipTypeID"];
32
33
		$dttm = (strtotime($killmail["killTime"]) * 10000000) + 116444736000000000;
34
35
		$string = "$victimID$attackerID$shipTypeID$dttm";
36
37
		$sha = sha1($string);
38
		return $sha;
39
	}
40
}
41