use of static in Range implementation.

This commit is contained in:
Jens True 2023-08-03 14:06:48 +00:00
parent e90b287096
commit eada4f87b3
4 changed files with 7 additions and 8 deletions

@ -9,7 +9,7 @@ use Exception;
class Range
{
public function __construct(private int $min, private int $max)
final public function __construct(private int $min, private int $max)
{
if ($min > $max) {
throw new Exception('min > max');
@ -26,9 +26,9 @@ class Range
return $this->max;
}
protected static function create(int $min, int $max): self
protected static function create(int $min, int $max): static
{
return new Range($min, $max);
return new static($min, $max);
}
// REVIEW: It's probably bad form to have access statics via a derived class, but the syntax looks better :-)

@ -6,8 +6,8 @@ use DNW\Skills\Numerics\Range;
class PlayersRange extends Range
{
protected static function create(int $min, int $max): self
protected static function create(int $min, int $max): static
{
return new PlayersRange($min, $max);
return new static($min, $max);
}
}

@ -6,8 +6,8 @@ use DNW\Skills\Numerics\Range;
class TeamsRange extends Range
{
protected static function create(int $min, int $max): self
protected static function create(int $min, int $max): static
{
return new TeamsRange($min, $max);
return new static($min, $max);
}
}

@ -61,7 +61,6 @@ class PlayerPriorValuesToSkillsLayer extends TrueSkillFactorGraphLayer
private function createPriorFactor(Rating $priorRating, Variable $skillsVariable): GaussianPriorFactor
{
echo (get_class($this->getParentFactorGraph()).PHP_EOL);
return new GaussianPriorFactor(
$priorRating->getMean(),
BasicMath::square($priorRating->getStandardDeviation()) +