TipsdataAjax::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass TipsdataAjax.
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\Spel;
14
use Tips\Klasser\Tips;
15
use Tips\Klasser\Sekvenser;
16
use Tips\Klasser\Tipsdata;
17
use Tips\Egenskaper\Ajax;
18
19
/**
20
 * Ajaxanrop ligger utanför ordinarie ordning.
21
 */
22
require_once dirname(__FILE__) . '/../../vendor/autoload.php';
23
new Preludium();
24
25
/**
26
 * Klass TipsdataAjax.
27
 * @SuppressWarnings("PHPMD.UnusedPrivateMethod")
28
 */
29
final class TipsdataAjax {
30
	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\TipsdataAjax.
Loading history...
31
32
	private Spel $spel;
33
	private Tips $tips;
34
	private Tipsdata $tipsdata;
35
36
	/**
37
	 * Inititiera.
38
	 */
39
	public function __construct() {
40
		$this->spel = new Spel();
41
		$this->tips = new Tips($this->spel);
42
		$this->tipsdata = new Tipsdata($this->spel);
43
		$this->förgrena();
44
	}
45
46
	/**
47
	 * Hämta data från Svenska spel.
48
	 * js/funktioner.js: hämta_tips
49
	 */
50
	private function hämta_tips(): void {
0 ignored issues
show
Unused Code introduced by
The method hämta_tips() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
51
		$resultat = match ($_REQUEST['hämta_tips']) {
52
			'hämta_tipsresultat' => $this->tipsdata->hämta_tipsresultat($this->tips),
53
			'hämta_tipsdata' => $this->tipsdata->hämta_tipsdata($this->tips),
54
			default => false
55
		};
56
57
		if ($resultat) {
58
			$this->tips->spara_tips();
59
			(new Sekvenser($this->tips->spel))->traversera_sekvenser();
60
			$this->db->spara_backup();
61
		}
62
	}
63
}
64
65
new TipsdataAjax();
66