Passed
Push — main ( 9152fd...203f91 )
by N.
03:37
created

SekvensAjax::radera_sekvens()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 3
nop 0
dl 0
loc 15
ccs 11
cts 11
cp 1
crap 3
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass SekvensAjax.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Ajax;
11
12
use Tips\Klasser\Preludium;
13
use Tips\Klasser\Speltyp;
14
use Tips\Klasser\Spel;
15
use Tips\Klasser\Tips;
16
use Tips\Egenskaper\Ajax;
17
18
/**
19
 * Ajaxanrop ligger utanför ordinarie ordning.
20
 */
21 1
require_once dirname(__FILE__) . '/../../vendor/autoload.php';
22 1
new Preludium();
23
24
/**
25
 * Klass SekvensAjax.
26
 * @SuppressWarnings("PHPMD.UnusedPrivateMethod")
27
 */
28
final class SekvensAjax {
29
	use Ajax;
0 ignored issues
show
Bug introduced by
The trait Tips\Egenskaper\Ajax requires the property $logg which is not provided by Tips\Ajax\SekvensAjax.
Loading history...
30
31
	private Spel $spel;
32
	private Tips $tips;
33
34
	/**
35
	 * Inititiera.
36
	 */
37 1
	public function __construct() {
38 1
		$this->spel = new Spel();
39 1
		$this->tips = new Tips($this->spel);
40 1
		$this->förgrena();
41
	}
42
43
	/**
44
	 * Radera sekvens.
45
	 * js/funktioner.js: radera_sekvens, omgång, speltyp
46
	 */
47 1
	private function radera_sekvens(): void {
48 1
		$sekvens = (int) filter_var($_REQUEST['radera_sekvens'], FILTER_VALIDATE_INT);
49 1
		$omgång = (int) filter_var($_REQUEST['omgång'], FILTER_VALIDATE_INT);
50 1
		$speltyp = Speltyp::From((int) filter_var($_REQUEST['speltyp'], FILTER_VALIDATE_INT));
51
52 1
		foreach ($this->tips->moduler->m_moduler as $m) {
53 1
			if (method_exists($m, 'radera_sekvens')) {
54 1
				$m->radera_sekvens($omgång, $speltyp, $sekvens);
55
			}
56
		}
57
58 1
		$this->tips->spelade->radera_sekvens($omgång, $speltyp, $sekvens);
59 1
		$this->spel->db->radera_sekvens('spel', $omgång, $speltyp, $sekvens);
60 1
		$this->spel->hämta_sekvenser();
61 1
		$this->spel->spara_spel();
62
	}
63
}
64
65
new SekvensAjax();
66