Passed
Push — main ( e5e48e...78d8c3 )
by N.
05:08
created

PreferenserAjax::php()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
ccs 8
cts 8
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Klass PreferenserAjax.
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\Databas;
14
use Tips\Egenskaper\Ajax;
15
use Tips\Inkludera\Konstanter;
16
17
/**
18
 * Ajaxanrop ligger utanför ordinarie ordning.
19
 */
20 1
require_once dirname(__FILE__) . '/../../vendor/autoload.php';
21 1
new Preludium();
22
23
/**
24
 * Klass PreferenserAjax.
25
 * @SuppressWarnings("PHPMD.UnusedPrivateMethod")
26
 */
27
final class PreferenserAjax {
28
	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\PreferenserAjax.
Loading history...
29
	use Konstanter;
30
31
	/**
32
	 * Inititiera.
33
	 */
34 1
	public function __construct() {
35 1
		$this->förgrena();
36
	}
37
38
	/**
39
	 * Spara preferens för API.
40
	 * js/funktioner.js: api
41
	 */
42 1
	private function api(): void {
0 ignored issues
show
Unused Code introduced by
The method api() 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...
43 1
		$this->db_preferenser->spara_preferens('preferenser.api', (string) filter_var($_REQUEST['api'], FILTER_SANITIZE_SPECIAL_CHARS));
44
	}
45
46
	/**
47
	 * Spara preferens för PHP.
48
	 * js/funktioner.js: php, fcgi
49
	 */
50 1
	private function php(): void {
0 ignored issues
show
Unused Code introduced by
The method php() 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 1
		$this->db_preferenser->spara_preferens(
52 1
			'preferenser.php',
53 1
			(string) filter_var($_REQUEST['php'], FILTER_SANITIZE_SPECIAL_CHARS)
54 1
		);
55
56 1
		$this->db_preferenser->spara_preferens(
57 1
			'preferenser.fcgi',
58 1
			(string) filter_var($_REQUEST['fcgi'], FILTER_SANITIZE_SPECIAL_CHARS)
59 1
		);
60
	}
61
62
	/**
63
	 * Spara preferens för trådar.
64
	 * js/funktioner.js: trådar
65
	 */
66 1
	private function trådar(): void {
0 ignored issues
show
Unused Code introduced by
The method trådar() 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...
67 1
		$trådar = filter_var($_REQUEST['trådar'], FILTER_VALIDATE_INT);
68 1
		$trådar = (in_array($trådar, TRÅDMÄNGD, true)) ? $trådar : 9;
69 1
		$this->db_preferenser->spara_preferens('preferenser.trådar', (string) $trådar);
70
	}
71
72
	/**
73
	 * Spara antal rader att generera.
74
	 * js/funktioner.js: antal_rader
75
	 */
76 1
	private function antal_rader(): void {
0 ignored issues
show
Unused Code introduced by
The method antal_rader() 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...
77 1
		$this->db_preferenser->validera_indata('antal_rader', MIN_RADER, MAX_RADER, MIN_RADER, 'preferenser.max_rader');
78
	}
79
80
	/**
81
	 * Spara vinstintervall för 13 rätt.
82
	 * js/funktioner.js: u13_min, u13_max
83
	 */
84 1
	private function u13_min(): void {
0 ignored issues
show
Unused Code introduced by
The method u13_min() 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...
85 1
		$u13_min = (int) $this->db_preferenser->validera_indata(
86 1
			'u13_min',
87 1
			self::U13_MIN_MIN,
0 ignored issues
show
Bug introduced by
The constant Tips\Ajax\PreferenserAjax::U13_MIN_MIN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
88 1
			self::U13_MIN_MAX,
0 ignored issues
show
Bug introduced by
The constant Tips\Ajax\PreferenserAjax::U13_MIN_MAX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
89 1
			self::U13_MIN_STD,
0 ignored issues
show
Bug introduced by
The constant Tips\Ajax\PreferenserAjax::U13_MIN_STD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
90 1
			'preferenser.u13_min'
91 1
		);
92
93 1
		$u13_max = (int) $this->db_preferenser->validera_indata(
94 1
			'u13_max',
95 1
			self::U13_MAX_MIN,
0 ignored issues
show
Bug introduced by
The constant Tips\Ajax\PreferenserAjax::U13_MAX_MIN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
96 1
			self::U13_MAX_MAX,
0 ignored issues
show
Bug introduced by
The constant Tips\Ajax\PreferenserAjax::U13_MAX_MAX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
97 1
			self::U13_MAX_STD,
0 ignored issues
show
Bug introduced by
The constant Tips\Ajax\PreferenserAjax::U13_MAX_STD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
98 1
			'preferenser.u13_max'
99 1
		);
100
101 1
		$this->db_preferenser->komparera_preferenser(
102 1
			$u13_min,
103 1
			$u13_max,
104 1
			self::U13_MIN_STD,
105 1
			self::U13_MAX_STD,
106 1
			'preferenser.u13_min',
107 1
			'preferenser.u13_max'
108 1
		);
109
	}
110
}
111
112
new PreferenserAjax();
113