code: public static function IPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0)
      {
          $rate = Functions::flattenSingleValue($rate);
          $per = (int) Functions::flattenSingleValue($per);
          $nper = (int) Functions::flattenSingleValue($nper);
          $pv = Functions::flattenSingleValue($pv);
          $fv = Functions::flattenSingleValue($fv);
          $type = (int) Functions::flattenSingleValue($type);
  
          // Validate parameters
          if ($type != 0 && $type != 1) {
              return Functions::NAN();
          }
          if ($per <= 0 || $per > $nper) {
              return Functions::VALUE();
          }
  
          // Calculate
          $interestAndPrincipal = self::interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type);
  
          return $interestAndPrincipal[0];
      }
docs: IPMT.
  
  Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.
  
  Excel Function:
  IPMT(rate,per,nper,pv[,fv][,type])
  
  @param float $rate Interest rate per period
  @param int $per Period for which we want to find the interest
  @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