Passed
Push — main ( d29be2...38376b )
by N.
03:16
created

Radera   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 55.56%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 35
ccs 10
cts 18
cp 0.5556
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A radera_omgång() 0 8 3
A radera_fil() 0 6 2
A radera_sekvens() 0 6 1
1
<?php
2
3
/**
4
 * Klass Radera.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\Distribution;
11
12
use Tips\Klasser\Speltyp;
13
use Tips\Moduler\DistributionGenerera\Generera;
14
15
/**
16
 * Klass Radera.
17
 */
18
class Radera extends Hamta {
19
	/**
20
	 * Radera omgång.
21
	 */
22
	public function radera_omgång(int $omgång, Speltyp $speltyp): void {
23
		$this->odds->spel->db->radera_omgång('distribution', $omgång, $speltyp);
24
		$this->odds->spel->db->logg->logga(self::class . ": ✅ Raderade distribution. ({$this->odds->spel->omgång})");
25
26
		$mönster = "*-t{$speltyp->value}-o$omgång-*";
27
		$glob = (array) glob(GRAF . DISTRIBUTION . "/$mönster.png");
0 ignored issues
show
Bug introduced by
The constant Tips\Moduler\Distribution\DISTRIBUTION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Distribution\GRAF was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
28
		foreach ($glob as $fil) {
29
			is_string($fil) and $this->radera_fil($fil);
30
		}
31
	}
32
33
	/**
34
	 * Radera sekvens.
35
	 */
36 1
	public function radera_sekvens(int $omgång, Speltyp $speltyp, int $sekvens): void {
37 1
		$this->odds->spel->db->radera_sekvens('distribution', $omgång, $speltyp, $sekvens);
38 1
		$filnamn = $this->odds->spel->filer->filnamn($omgång, $speltyp, $sekvens);
39
40 1
		$fil = GRAF . DISTRIBUTION . "/$filnamn.png";
0 ignored issues
show
Bug introduced by
The constant Tips\Moduler\Distribution\DISTRIBUTION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Distribution\GRAF was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
41 1
		$this->radera_fil($fil);
42
	}
43
44
	/**
45
	 * Radera fil.
46
	 */
47 1
	private function radera_fil(string $fil): void {
48 1
		$kommentar = match (file_exists($fil) && unlink($fil)) {
49
			true => ": ✅ Raderade fil",
50 1
			false => ": ❌ Kunde inte radera fil"
51 1
		};
52 1
		$this->odds->spel->db->logg->logga(self::class . "$kommentar $fil");
53
	}
54
}
55