私はそのようなクラスがあります。だから、異なる自己クラスメソッドで配列クラスプロパティを使用するには?
class Calculator
{
protected $date;
protected $capital;
protected $rate;
protected $frequency;
protected $duration;
protected $charges;
protected $forcedPayments;
protected $result_array;
protected $chargesArray;
public function constantAmortization($date, $capital, $rate, $duration, $frequency, $charges)
{
$allPayments = $allInterests = array();
$amortization = $capital/$duration;
$interestTotal = 0; $amortizationTotal = 0;
for($i = 0; $i < $duration; $i++){
$interest = $capital * ($rate/100)/$frequency;
array_push($allInterests,$interest);
$payment = $amortization + $interest;
array_push($allPayments,$payment);
$remaining = $capital - $amortization;
//calculate totals for table headers output in twig :
$interestTotal += $interest; $amortizationTotal += $amortization;
$inverseCapital = $capital * -1;
$paymentTotal = $amortizationTotal + $interestTotal;
$this->result_array[$i] = result_array(
'Date' => $date->format('d/m/y'),
'Capital' => $capital,
'Rate' => $rate,
'Interest' => $interest,
'Payment' => $payment,
'Amortization' => $amortization,
'Remaining' => $remaining,
'InterestTotal' => $interestTotal,
'AmortizationTotal' => $amortizationTotal,
'PaymentTotal' => $paymentTotal,
'InverseCapital' => $inverseCapital,
);
$capital = $remaining;
$months = (12/$frequency). ' months';
$date->modify($months);
}
}
は、この方法では、クラスのプロパティに基づいて、クラスの「array_result」プロパティは私のフロントエンドには、後にoutputedされている値で満たされています。
私はcharge()というメソッドを用意しています。このメソッドは異なる計算を行い、クラスのchargesArrayプロパティに値を入力します。これもフロントエンドで出力されます。
私は関数を改良しなければならないので、私はconstantAmortization()メソッドの各繰り返しで、初期値のパーセント/残量として課金の値を作るために、charges()メソッドで何かを実装する必要があります。
どうすればいいですか?私の考えでは、私のcharges()メソッド内でresult_arrayプロパティを使用して、この配列を反復し、いくつかの計算を行うために大文字と残りの値に基づいている必要がありますが、 charges()メソッド私がしなければならないこと?ここ