Passed
Push — main ( b436ac...f1b4ad )
by N.
04:39
created

Rendera   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 34
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rendera() 0 4 1
A percentage_lines() 0 18 4
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 1
	protected function percentage_lines(float $andel, int $x, string $xkoord): void {
20 1
		$data = [
21 1
			'10' => [10.0, $this->dist->graf->grön, 80],
22 1
			'5' => [5.0, $this->dist->graf->grön_v[7], 100],
23 1
			'3' => [3.0, $this->dist->graf->grön_v[5], 120],
24 1
			'2' => [2.0, $this->dist->graf->grön_v[3], 140],
25 1
			'1' => [1.0, $this->dist->graf->grön_v[2], 160],
26 1
			'0.5' => [0.5, $this->dist->graf->grön_v[1], 180]
27 1
		];
28
29 1
		foreach ($data as $index => $punkt) {
30 1
			if (!$this->andel_vid[$index] && $andel > $punkt[0]) {
31 1
				$this->rendera(
32 1
					$this->andel_vid[$index],
33 1
					$x,
34 1
					$punkt[1],
35 1
					$punkt[2],
36 1
					"$index % vid: $xkoord"
37 1
				);
38
			}
39
		}
40
	}
41
42
	/**
43
	 * Rendera linjer och text.
44
	 */
45 1
	private function rendera(bool &$andel, int $x, int $färg, int $y, string $text): void {
46 1
		$andel = true;
47 1
		$this->dist->graf->sätt_linje($x, 0, $x, $this->dist->graf->höjd, $färg);
48 1
		$this->dist->graf->sätt_text(20, $y, $text, $this->dist->graf->grön);
49
	}
50
}
51