Killmail::getCrestHash()   B
last analyzed

Complexity

Conditions 6
Paths 24

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 25
rs 8.439
cc 6
eloc 15
nc 24
nop 1
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