Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Statistical.php
public static function AVERAGEIF($aArgs, $condition, $averageArgs = [])
    {
        $returnValue = 0;

        $aArgs = Functions::flattenArray($aArgs);
        $averageArgs = Functions::flattenArray($averageArgs);
        if (empty($averageArgs)) {
            $averageArgs = $aArgs;
        }
        $condition = Functions::ifCondition($condition);
        // Loop through arguments
        $aCount = 0;
        foreach ($aArgs as $key => $arg) {
            if (!is_numeric($arg)) {
                $arg = Calculation::wrapResult(strtoupper($arg));
            }
            $testCondition = '=' . $arg . $condition;
            if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
                if (($returnValue === null) || ($arg > $returnValue)) {
                    $returnValue += $arg;
                    ++$aCount;
                }
            }
        }

        if ($aCount > 0) {
            return $returnValue / $aCount;
        }

        return Functions::DIV0();
    }
public static function AVERAGEIF($aArgs, $condition, $averageArgs = [])
    {
        $returnValue = 0;

        $aArgs = Functions::flattenArray($aArgs);
        $averageArgs = Functions::flattenArray($averageArgs);
        if (empty($averageArgs)) {
            $averageArgs = $aArgs;
        }
        $condition = Functions::ifCondition($condition);
        // Loop through arguments
        $aCount = 0;
        foreach ($aArgs as $key => $arg) {
            if (!is_numeric($arg)) {
                $arg = Calculation::wrapResult(strtoupper($arg));
            }
            $testCondition = '=' . $arg . $condition;
            if (Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
                if (($returnValue === null) || ($arg > $returnValue)) {
                    $returnValue += $arg;
                    ++$aCount;
                }
            }
        }

        if ($aCount > 0) {
            return $returnValue / $aCount;
        }

        return Functions::DIV0();
    }
AVERAGEIF.

Returns the average value from a range of cells that contain numbers within the list of arguments

Excel Function:
AVERAGEIF(value1[,value2[, ...]],condition)

@category Mathematical and Trigonometric Functions

@param mixed $aArgs Data values
@param string $condition the criteria that defines which cells will be checked
@param mixed[] $averageArgs Data values

@return float