Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Failed Conditions
Push — master ( 20c993...94c36f )
by Dan
23s queued 18s
created

UserRanking::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Smr;
4
5
/**
6
 * User ranking titles
7
 */
8
class UserRanking {
9
10
	const NAMES = [
11
		1 => 'Newbie',
12
		2 => 'Beginner',
13
		3 => 'Fledgling',
14
		4 => 'Average',
15
		5 => 'Adept',
16
		6 => 'Expert',
17
		7 => 'Elite',
18
		8 => 'Master',
19
		9 => 'Grandmaster',
20
	];
21
22
	const MIN_RANK = 1;
23
	const MAX_RANK = 9;
24
25
	const SCORE_POW = .3;
26
	const SCORE_POW_RANK_INCREMENT = 5.2;
27
28
	/**
29
	 * Given a score, return the associated rank
30
	 */
31
	public static function getRankFromScore(int $score) : int {
32
		$rank = ICeil(pow($score, self::SCORE_POW) / self::SCORE_POW_RANK_INCREMENT);
33
		$rank = min(max($rank, self::MIN_RANK), self::MAX_RANK);
34
		return $rank;
35
	}
36
37
	/**
38
	 * Given a rank, return the minimum score needed to achieve it
39
	 * (this is an inversion of getRankFromScore)
40
	 */
41
	public static function getMinScoreForRank(int $rank) : int {
42
		return ICeil(pow(($rank - 1) * self::SCORE_POW_RANK_INCREMENT, 1 / self::SCORE_POW));
43
	}
44
45
	/**
46
	 * Return the title associated with the given rank
47
	 */
48
	public static function getName(int $rank) : string {
49
		return self::NAMES[$rank];
50
	}
51
52
	public static function getAllNames() : array {
53
		return self::NAMES;
54
	}
55
56
}
57