No more use of $_ to mark private members.

This commit is contained in:
2023-08-02 09:15:01 +00:00
parent 32b8a9d83e
commit 16ad8175d9
10 changed files with 71 additions and 71 deletions

View File

@ -4,13 +4,13 @@ namespace DNW\Skills\FactorGraphs;
class KeyedVariable extends Variable
{
public function __construct(private mixed $_key, string $name, mixed $prior)
public function __construct(private mixed $key, string $name, mixed $prior)
{
parent::__construct($name, $prior);
}
public function getKey(): mixed
{
return $this->_key;
return $this->key;
}
}

View File

@ -4,22 +4,22 @@ namespace DNW\Skills\FactorGraphs;
class Message implements \Stringable
{
public function __construct(private $_value = null, private $_name = null)
public function __construct(private $value = null, private $name = null)
{
}
public function getValue()
{
return $this->_value;
return $this->value;
}
public function setValue($value)
{
$this->_value = $value;
$this->value = $value;
}
public function __toString(): string
{
return (string) $this->_name;
return $this->name;
}
}

View File

@ -4,7 +4,7 @@ namespace DNW\Skills\FactorGraphs;
class ScheduleLoop extends Schedule
{
public function __construct($name, private readonly Schedule $_scheduleToLoop, private $_maxDelta)
public function __construct($name, private readonly Schedule $scheduleToLoop, private $maxDelta)
{
parent::__construct($name);
}
@ -12,9 +12,9 @@ class ScheduleLoop extends Schedule
public function visit(int $depth = -1, int $maxDepth = 0)
{
$totalIterations = 1;
$delta = $this->_scheduleToLoop->visit($depth + 1, $maxDepth);
while ($delta > $this->_maxDelta) {
$delta = $this->_scheduleToLoop->visit($depth + 1, $maxDepth);
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
while ($delta > $this->maxDelta) {
$delta = $this->scheduleToLoop->visit($depth + 1, $maxDepth);
$totalIterations++;
}

View File

@ -4,7 +4,7 @@ namespace DNW\Skills\FactorGraphs;
class ScheduleSequence extends Schedule
{
public function __construct($name, private readonly array $_schedules)
public function __construct($name, private readonly array $schedules)
{
parent::__construct($name);
}
@ -13,7 +13,7 @@ class ScheduleSequence extends Schedule
{
$maxDelta = 0;
$schedules = $this->_schedules;
$schedules = $this->schedules;
foreach ($schedules as $currentSchedule) {
$currentVisit = $currentSchedule->visit($depth + 1, $maxDepth);
$maxDelta = max($currentVisit, $maxDelta);

View File

@ -4,15 +4,15 @@ namespace DNW\Skills\FactorGraphs;
class ScheduleStep extends Schedule
{
public function __construct($name, private readonly Factor $_factor, private $_index)
public function __construct($name, private readonly Factor $factor, private $index)
{
parent::__construct($name);
}
public function visit(int $depth = -1, int $maxDepth = 0)
{
$currentFactor = $this->_factor;
$currentFactor = $this->factor;
return $currentFactor->updateMessageIndex($this->_index);
return $currentFactor->updateMessageIndex($this->index);
}
}

View File

@ -4,20 +4,20 @@ namespace DNW\Skills\FactorGraphs;
class VariableFactory
{
public function __construct(private $_variablePriorInitializer)
public function __construct(private $variablePriorInitializer)
{
}
public function createBasicVariable(string $name): Variable
{
$initializer = $this->_variablePriorInitializer;
$initializer = $this->variablePriorInitializer;
return new Variable($name, $initializer());
}
public function createKeyedVariable(mixed $key, string $name): KeyedVariable
{
$initializer = $this->_variablePriorInitializer;
$initializer = $this->variablePriorInitializer;
return new KeyedVariable($key, $name, $initializer());
}