code: public static function PMT($rate = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0)
      {
          $rate = Functions::flattenSingleValue($rate);
          $nper = Functions::flattenSingleValue($nper);
          $pv = Functions::flattenSingleValue($pv);
          $fv = Functions::flattenSingleValue($fv);
          $type = Functions::flattenSingleValue($type);
  
          // Validate parameters
          if ($type != 0 && $type != 1) {
              return Functions::NAN();
          }
  
          // Calculate
          if ($rate !== null && $rate != 0) {
              return (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate);
          }
  
          return (-$pv - $fv) / $nper;
      }
docs: PMT.
  
  Returns the constant payment (annuity) for a cash flow with a constant interest rate.
  
  @param float $rate Interest rate per period
  @param int $nper Number of periods
  @param float $pv Present Value
  @param float $fv Future Value
  @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period
  
  @return float