amountIndexes as $index) { /** * @var string $index */ if (isset($this->$index)) { $amount = (float)$this->$index; $this->$index = $amount * $rate; } } } }