Passed
Push — main ( f1b4ad...6ccac6 )
by N.
04:46
created

Rendera::rendera()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 5
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass Rendera.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\DistributionGenerera;
11
12
/**
13
 * Klass Rendera.
14
 */
15
class Rendera extends Oddssummor {
16
	/**
17
	 * Rita procentsatser med linjer i gröna nyanser.
18
	 */
19
	protected function percentage_lines(float $andel, int $x, string $xkoord): void {
20
		$data = [
21
			'10' => [10.0, $this->dist->graf->grön, 80],
22
			'5' => [5.0, $this->dist->graf->grön_v[7], 100],
23
			'3' => [3.0, $this->dist->graf->grön_v[5], 120],
24
			'2' => [2.0, $this->dist->graf->grön_v[3], 140],
25
			'1' => [1.0, $this->dist->graf->grön_v[2], 160],
26
			'0.5' => [0.5, $this->dist->graf->grön_v[1], 180]
27
		];
28
29
		foreach ($data as $index => $punkt) {
30
			if (!$this->andel_vid[$index] && $andel > $punkt[0]) {
31
				$this->rendera(
32
					$this->andel_vid[$index],
33
					$x,
34
					$punkt[1],
35
					$punkt[2],
36
					"$index % vid: $xkoord"
37
				);
38
			}
39
		}
40
	}
41
42
	/**
43
	 * Rendera linjer och text.
44
	 */
45
	private function rendera(bool &$andel, int $x, int $färg, int $y, string $text): void {
46
		$andel = true;
47
		$this->dist->graf->sätt_linje($x, 0, $x, $this->dist->graf->höjd, $färg);
48
		$this->dist->graf->sätt_text(20, $y, $text, $this->dist->graf->grön);
49
	}
50
}
51