app/Statistics/Repository/IndividualRepository.php
private function averageLifespanQuery(string $sex, bool $show_years): string
    {
        $prefix = DB::connection()->getTablePrefix();

        $days = (int) $this->birthAndDeathQuery($sex)
            ->select(DB::raw('AVG(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) AS days'))
            ->value('days');

        if ($show_years) {
            return $this->calculateAge($days);
        }

        return I18N::number((int) ($days / 365.25));
    }
private function averageLifespanQuery(string $sex, bool $show_years): string
    {
        $prefix = DB::connection()->getTablePrefix();

        $days = (int) $this->birthAndDeathQuery($sex)
            ->select(DB::raw('AVG(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) AS days'))
            ->value('days');

        if ($show_years) {
            return $this->calculateAge($days);
        }

        return I18N::number((int) ($days / 365.25));
    }
private function averageLifespanQuery ( string $ sex , bool $ show_years ) : string { $ prefix = DB :: connection ( ) -> getTablePrefix ( ) ; $ days = ( int ) $ this -> birthAndDeathQuery ( $ sex ) -> select ( DB :: raw ( 'AVG(' . $ prefix . 'death.d_julianday2 - ' . $ prefix . 'birth.d_julianday1) AS days' ) ) -> value ( 'days' ) ; if ( $ show_years ) { return $ this -> calculateAge ( $ days ) ; } return I18N :: number ( ( int ) ( $ days / 365.25 ) ) ; }
Find the average lifespan.

@param string $sex        "M", "F" or "BOTH"
@param bool   $show_years

@return string
Find the average lifespan .