@@ 24-48 (lines=25) @@ | ||
21 | private $weight; |
|
22 | private $polynom; |
|
23 | ||
24 | public function __construct(array $config) |
|
25 | { |
|
26 | if ( |
|
27 | !isset($config['weight']) || |
|
28 | !isset($config['polynom']) |
|
29 | ) { |
|
30 | throw new LogicException; |
|
31 | } |
|
32 | ||
33 | $this->weight = new Weight(new Number($config['weight'])); |
|
34 | $polynom = new Polynom; |
|
35 | ||
36 | if (isset($config['polynom']['intercept'])) { |
|
37 | $polynom = new Polynom(new Number($config['polynom']['intercept'])); |
|
38 | } |
|
39 | ||
40 | foreach ($config['polynom']['degrees'] ?? [] as $degree => $coeff) { |
|
41 | $polynom = $polynom->withDegree( |
|
42 | new Integer($degree), |
|
43 | new Number($coeff) |
|
44 | ); |
|
45 | } |
|
46 | ||
47 | $this->polynom = $polynom; |
|
48 | } |
|
49 | ||
50 | public function make(TimeContinuumInterface $clock, Server $server): Cpu |
|
51 | { |
@@ 25-49 (lines=25) @@ | ||
22 | private $weight; |
|
23 | private $polynom; |
|
24 | ||
25 | public function __construct(array $config) |
|
26 | { |
|
27 | if ( |
|
28 | !isset($config['weight']) || |
|
29 | !isset($config['polynom']) |
|
30 | ) { |
|
31 | throw new LogicException; |
|
32 | } |
|
33 | ||
34 | $this->weight = new Weight(new Number($config['weight'])); |
|
35 | $polynom = new Polynom; |
|
36 | ||
37 | if (isset($config['polynom']['intercept'])) { |
|
38 | $polynom = new Polynom(new Number($config['polynom']['intercept'])); |
|
39 | } |
|
40 | ||
41 | foreach ($config['polynom']['degrees'] ?? [] as $degree => $coeff) { |
|
42 | $polynom = $polynom->withDegree( |
|
43 | new Integer($degree), |
|
44 | new Number($coeff) |
|
45 | ); |
|
46 | } |
|
47 | ||
48 | $this->polynom = $polynom; |
|
49 | } |
|
50 | ||
51 | public function make( |
|
52 | TimeContinuumInterface $clock, |