Returns the headers for the csv file based on the indicators and the target.

@param \core_analytics\local\time_splitting\base $timesplitting
@param \core_analytics\local\target\base $target
@return string[]
977066
public function get_headers(\core_analytics\local\time_splitting\base $timesplitting,
            \core_analytics\local\target\base $target): array {
        // 3rd column will contain the indicator ids.
        $headers = array();

        if (!$this->includetarget) {
            // The first column is the sampleid.
            $headers[] = 'sampleid';
        }

        // We always have 1 column for each time splitting method range, it does not depend on how
        // many ranges we calculated.
        $ranges = $timesplitting->get_distinct_ranges();
        if (count($ranges) > 1) {
            foreach ($ranges as $rangeindex) {
                $headers[] = 'range/' . $rangeindex;
            }
        }

        // Model indicators.
        foreach ($this->analyser->get_indicators() as $indicator) {
            $headers = array_merge($headers, $indicator::get_feature_headers());
        }

        // The target as well.
        if ($this->includetarget) {
            $headers[] = $target->get_id();
        }

        return $headers;
    }
1358522
protected function getHeaderKeys(bool $legacy = true): array
    {
        // We always want this
        $return = [
            $this->reportOnly
                ? 'Content-Security-Policy-Report-Only'
                : 'Content-Security-Policy'
        ];

        // If we're supporting legacy devices, include these too:
        if ($legacy) {
            $return []= $this->reportOnly
                ? 'X-Content-Security-Policy-Report-Only'
                : 'X-Content-Security-Policy';
            $return []= $this->reportOnly
                ? 'X-Webkit-CSP-Report-Only'
                : 'X-Webkit-CSP';
        }
        return $return;
    }
672142
private function _getLevelAndTargetLoggers( $target )
    {
        $target = strpos($target, ':') !== false ? explode( ':' , $target ) : ['', '*'];
        list($level,$target_loggers) = $target;
        $target_loggers = explode( ',' , $target_loggers );
        $target_loggers = array_map( 'trim', $target_loggers );
        if (in_array('*',$target_loggers))
        {
            $target_loggers = array_keys($this->loggers);
        }
        return array( $level, $target_loggers );
    }
363186
protected function _getStrings(&$position, $target)
    {
        $strings = [];
        $count = count($strings);
        while ($count < $target && ($this->_tokens[$position] === ',' || $this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING || $this->_tokens[$position][0] == T_LNUMBER)) {
            $count = count($strings);
            if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING && $this->_tokens[$position + 1] === '.') {
                $string = '';
                while ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING || $this->_tokens[$position] === '.') {
                    if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
                        $string .= $this->_formatString($this->_tokens[$position][1]);
                    }
                    $position++;
                }
                $strings[] = $string;
            } elseif ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
                $strings[] = $this->_formatString($this->_tokens[$position][1]);
            } elseif ($this->_tokens[$position][0] == T_LNUMBER) {
                $strings[] = $this->_tokens[$position][1];
            }
            $position++;
        }

        return $strings;
    }
976209
private function parseForecastResponseHeaders($headers)
    {
        $responseHeaders = [
            'cache' => [
                'maxAge' => null,
                'expires' => null
            ],
            'responseTime' => null,
            'apiCalls' => null
        ];
        foreach ($headers as $header) {
            switch (true) {
                case (substr($header, 0, 14) === 'Cache-Control:'):
                    $responseHeaders['cache']['maxAge'] = trim(substr($header, strrpos($header, '=') + 1));
                    break;
                case (substr($header, 0, 8) === 'Expires:'):
                    $responseHeaders['cache']['expires'] = trim(substr($header, 8));
                    break;
                case (substr($header, 0, 21) === 'X-Forecast-API-Calls:'):
                    $responseHeaders['apiCalls'] = trim(substr($header, 21));
                    break;
                case (substr($header, 0, 16) === 'X-Response-Time:'):
                    $responseHeaders['responseTime'] = (int)trim(substr($header, 16));
                    break;
                default:
                    break;
            }
        }
        return $responseHeaders;
    }
443658
protected function getBestNumericalSplit(array $samples, array $targets, int $col): array
    {
        $values = array_column($samples, $col);
        // Trying all possible points may be accomplished in two general ways:
        // 1- Try all values in the $samples array ($values)
        // 2- Artificially split the range of values into several parts and try them
        // We choose the second one because it is faster in larger datasets
        $minValue = min($values);
        $maxValue = max($values);
        $stepSize = ($maxValue - $minValue) / $this->numSplitCount;

        $split = [];

        foreach (['<=', '>'] as $operator) {
            // Before trying all possible split points, let's first try
            // the average value for the cut point
            $threshold = array_sum($values) / (float) count($values);
            [$errorRate, $prob] = $this->calculateErrorRate($targets, $threshold, $operator, $values);
            if (!isset($split['trainingErrorRate']) || $errorRate < $split['trainingErrorRate']) {
                $split = [
                    'value' => $threshold,
                    'operator' => $operator,
                    'prob' => $prob,
                    'column' => $col,
                    'trainingErrorRate' => $errorRate,
                ];
            }

            // Try other possible points one by one
            for ($step = $minValue; $step <= $maxValue; $step += $stepSize) {
                $threshold = (float) $step;
                [$errorRate, $prob] = $this->calculateErrorRate($targets, $threshold, $operator, $values);
                if ($errorRate < $split['trainingErrorRate']) {
                    $split = [
                        'value' => $threshold,
                        'operator' => $operator,
                        'prob' => $prob,
                        'column' => $col,
                        'trainingErrorRate' => $errorRate,
                    ];
                }
            }// for
        }

        return $split;
    }
91728
private static function extractHeaders($headers, Translations $translations)
    {
        $headers = explode("\n", $headers);
        $currentHeader = null;

        foreach ($headers as $line) {
            $line = self::convertString($line);

            if ($line === '') {
                continue;
            }

            if (self::isHeaderDefinition($line)) {
                $header = \array_map('\trim', \explode(':', $line, 2));
                $currentHeader = $header[0];
                $translations->setHeader($currentHeader, $header[1]);
            } else {
                $entry = $translations->getHeader($currentHeader);
                $translations->setHeader($currentHeader, $entry.$line);
            }
        }
    }
1238094
protected function interpretSpecialTargets(array $targets)
    {
        $normalized = [];

        foreach ($targets as $targetParts) {

            // Detect '*' and convert to all attributes
            if (count($targetParts) == 1 && trim(head($targetParts)) == '*') {
                $normalized += $this->makeTargetsForAllAttributes();
                continue;
            }

            $normalized[] = $targetParts;
        }

        return $normalized;
    }
180151
private function getCompleteCollectionNamespace($target)
    {
        if (mb_strpos($target, '.') !== false) {
            return explode('.', $target);
        }

        return [$this->getDatabase()->getName(), $target];
    }
901659
private function formatTimestampForApi($value)
    {
        list ($dt, $nanos) = $this->parseTimeString($value);

        return [
            'seconds' => (int) $dt->format('U'),
            'nanos' => (int) $nanos
        ];
    }
146004
def _GetTimelineItems(client_id, file_path):
  """"""

  items = []

  for file_path, stat_entry, _ in _GetTimelineStatEntries(
      client_id, file_path, with_history=True):

    # It may be that for a given timestamp only hash entry is available, we're
    # skipping those.
    if stat_entry is None:
      continue

    # Add a new event for each MAC time if it exists.
    for c in "mac":
      timestamp = getattr(stat_entry, "st_%stime" % c)
      if timestamp is None:
        continue

      item = ApiVfsTimelineItem()
      item.timestamp = rdfvalue.RDFDatetime.FromSecondsSinceEpoch(timestamp)

      # Remove aff4:/<client_id> to have a more concise path to the
      # subject.
      item.file_path = file_path
      if c == "m":
        item.action = ApiVfsTimelineItem.FileActionType.MODIFICATION
      elif c == "a":
        item.action = ApiVfsTimelineItem.FileActionType.ACCESS
      elif c == "c":
        item.action = ApiVfsTimelineItem.FileActionType.METADATA_CHANGED

      items.append(item)

  return sorted(items, key=lambda x: x.timestamp, reverse=True)
761453
public function targets(): Targets
    {
        if (!isset($this->_merged)) {
            $a = array();
            foreach ($this->_targets as $targets) {
                $a = array_merge($a, $targets->all());
            }
            $this->_merged = new Targets(...$a);
        }
        return $this->_merged;
    }
64808
private function timeAgo($timestamp) {
    $now = new \DateTime('now');
    $date = new \DateTime();
    $date->setTimestamp($timestamp);
    $datediff = date_diff($now, $date);
    $message = '';
    $components = [
      ['y', 'year', 'years'], ['m', 'month', 'months'],
      ['d', 'day', 'days'], ['h', 'hour', 'hours'],
      ['i', 'minute', 'minutes'], ['s', 'second', 'seconds'],
    ];
    foreach ($components as $component) {
      if ($datediff->{$component[0]} > 0) {
        $message = $datediff->{$component[0]} . ' '
          . ($datediff->{$component[0]} > 1 ? t($component[2]) : $component[1]);
        break;
      }
    }
    return !empty($message) ? $message . ' ' . t('ago') : '';
  }
418793
private function formatTimestampFromApi(array $timestamp)
    {
        $timestamp += [
            'seconds' => 0,
            'nanos' => 0
        ];

        $dt = $this->createDateTimeFromSeconds($timestamp['seconds']);

        return $this->formatTimeAsString($dt, $timestamp['nanos']);
    }
14440
public function getTimeline(DataObject $member, $sortBy = 'ID',  $since = 0, $before = false, $topLevelOnly = true, $tags = array(), $offset = 0, $number = 10) {
		$following = $this->friendsList($member);

		// TODO Following points to a list of Profile IDs, NOT user ids.
		$number = (int) $number;
		$userIds = array();
		if ($following) {
			$userIds = $following->map('OtherID', 'OtherID');
			$userIds = $userIds->toArray();
		}

		$userIds[] = $member->ID;
		
		$filter = array(
			'OwnerID' => $userIds, 
		);
		
		return $this->microPostList($filter, $sortBy, $since, $before, $topLevelOnly, $tags, $offset, $number);
	}
401548
final public function getLastUpdatedTimestamp($path)
    {
        $commits = $this->commitsForFile($path);

        $updated = array_shift($commits);

        $time = new \DateTime($updated['commit']['committer']['date']);

        return ['timestamp' => $time->getTimestamp()];
    }
795406
public function getHeaders(array $include = [])
    {
        if ($include == array_values($include)) {
            $include = array_fill_keys($include, true);
        }
        $defaults = array_fill_keys(
            [
                'from', 'sender', 'replyTo', 'readReceipt', 'returnPath',
                'to', 'cc', 'bcc', 'subject'],
            false
        );
        $include += $defaults;

        $headers = [];
        $relation = [
            'from' => 'From',
            'replyTo' => 'Reply-To',
            'readReceipt' => 'Disposition-Notification-To',
            'returnPath' => 'Return-Path'
        ];
        foreach ($relation as $var => $header) {
            if ($include[$var]) {
                $var = '_' . $var;
                $headers[$header] = current($this->_formatAddress($this->{$var}));
            }
        }
        if ($include['sender']) {
            if (key($this->_sender) === key($this->_from)) {
                $headers['Sender'] = '';
            } else {
                $headers['Sender'] = current($this->_formatAddress($this->_sender));
            }
        }

        foreach (['to', 'cc', 'bcc'] as $var) {
            if ($include[$var]) {
                $classVar = '_' . $var;
                $headers[ucfirst($var)] = implode(', ', $this->_formatAddress($this->{$classVar}));
            }
        }

        $headers += $this->_headers;
        if (!isset($headers['Date'])) {
            $headers['Date'] = date(DATE_RFC2822);
        }
        if ($this->_messageId !== false) {
            if ($this->_messageId === true) {
                $this->_messageId = '<' . str_replace('-', '', Text::uuid()) . '@' . $this->_domain . '>';
            }

            $headers['Message-ID'] = $this->_messageId;
        }

        if ($this->_priority) {
            $headers['X-Priority'] = $this->_priority;
        }

        if ($include['subject']) {
            $headers['Subject'] = $this->_subject;
        }

        $headers['MIME-Version'] = '1.0';
        if ($this->_attachments) {
            $headers['Content-Type'] = 'multipart/mixed; boundary="' . $this->_boundary . '"';
        } elseif ($this->_emailFormat === 'both') {
            $headers['Content-Type'] = 'multipart/alternative; boundary="' . $this->_boundary . '"';
        } elseif ($this->_emailFormat === 'text') {
            $headers['Content-Type'] = 'text/plain; charset=' . $this->_getContentTypeCharset();
        } elseif ($this->_emailFormat === 'html') {
            $headers['Content-Type'] = 'text/html; charset=' . $this->_getContentTypeCharset();
        }
        $headers['Content-Transfer-Encoding'] = $this->_getContentTransferEncoding();

        return $headers;
    }