DistributionAjax   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 39
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A grund_minprocent() 0 4 1
A distribution_minprocent() 0 5 1
A __construct() 0 5 1
A attraktionsfaktor() 0 2 1
1
<?php
2
3
/**
4
 * Klass DistributionAjax.
5
 * @author Niklas Dougherty
6
 */
7
8
declare(strict_types=1);
9
10
namespace Tips\Moduler\Ajax;
11
12
use Tips\Klasser\Preludium;
13
use Tips\Klasser\Spel;
14
use Tips\Klasser\Tips;
15
use Tips\Moduler\Distribution;
16
use Tips\Egenskaper\Ajax;
17
use Tips\Moduler\Distribution\Konstanter;
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 DistributionAjax.
27
 * @SuppressWarnings("PHPMD.UnusedPrivateMethod")
28
 */
29
final class DistributionAjax {
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\Moduler\Ajax\DistributionAjax.
Loading history...
31
	use Konstanter;
32
33
	private Spel $spel;
34
	private Tips $tips;
35
	private Distribution $distribution;
36
37
	public function __construct() {
38
		$this->spel = new Spel();
39
		$this->tips = new Tips($this->spel);
40
		$this->distribution = new Distribution($this->tips->utdelning, $this->tips->odds, $this->tips->streck, $this->tips->matcher);
41
		$this->förgrena();
42
	}
43
44
	/**
45
	 * Håll minprocent inom godtagbara intervall.
46
	 */
47
	private function distribution_minprocent(): void {
0 ignored issues
show
Unused Code introduced by
The method distribution_minprocent() 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...
48
		$this->distribution->minprocent = (float) $this->db_preferenser->validera_indata('distribution_minprocent', self::DISTRIBUTION_GRUND_MIN_MIN, self::DISTRIBUTION_GRUND_MIN_MAX, self::DISTRIBUTION_GRUND_MIN_STD, 'distribution.minprocent');
0 ignored issues
show
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MIN_STD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MIN_MIN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MIN_MAX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
49
		$this->distribution->maxprocent = (float) $this->db_preferenser->validera_indata('distribution_maxprocent', self::DISTRIBUTION_GRUND_MAX_MIN, self::DISTRIBUTION_GRUND_MAX_MAX, self::DISTRIBUTION_GRUND_MAX_STD, 'distribution.maxprocent');
0 ignored issues
show
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MAX_MAX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MAX_MIN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MAX_STD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
50
		$this->db_preferenser->komparera_preferenser($this->distribution->minprocent, $this->distribution->maxprocent, self::DISTRIBUTION_GRUND_MIN_STD, self::DISTRIBUTION_GRUND_MAX_STD, 'distribution.minprocent', 'distribution.maxprocent');
51
		$this->distribution->spara_omgång($this->tips);
52
	}
53
54
	/**
55
	 * Håll grundläggande minprocent inom godtagbara intervall.
56
	 */
57
	private function grund_minprocent(): void {
0 ignored issues
show
Unused Code introduced by
The method grund_minprocent() 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...
58
		$grund_minprocent = (float) $this->db_preferenser->validera_indata('grund_minprocent', self::DISTRIBUTION_GRUND_MIN_MIN, self::DISTRIBUTION_GRUND_MIN_MAX, self::DISTRIBUTION_GRUND_MIN_STD, 'distribution.grund_minprocent');
0 ignored issues
show
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MIN_MIN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MIN_STD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MIN_MAX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
59
		$grund_maxprocent = (float) $this->db_preferenser->validera_indata('grund_maxprocent', self::DISTRIBUTION_GRUND_MAX_MIN, self::DISTRIBUTION_GRUND_MAX_MAX, self::DISTRIBUTION_GRUND_MAX_STD, 'distribution.grund_maxprocent');
0 ignored issues
show
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MAX_MIN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MAX_MAX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Tips\Moduler\Ajax\Distri...TRIBUTION_GRUND_MAX_STD was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
60
		$this->db_preferenser->komparera_preferenser($grund_minprocent, $grund_maxprocent, self::DISTRIBUTION_GRUND_MIN_STD, self::DISTRIBUTION_GRUND_MAX_STD, 'distribution.grund_minprocent', 'distribution.grund_maxprocent');
61
	}
62
63
	/**
64
	 * Spara attraktionsfaktor.
65
	 */
66
	private function attraktionsfaktor(): void {
0 ignored issues
show
Unused Code introduced by
The method attraktionsfaktor() 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
		$this->ändra_attraktionsfaktor('distribution');
68
	}
69
}
70
71
new DistributionAjax();
72