You are here

public function FileProfilerStorage::find in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php \Symfony\Component\HttpKernel\Profiler\FileProfilerStorage::find()

Finds profiler tokens for the given criteria.

Parameters

string $ip The IP:

string $url The URL:

string $limit The maximum number of tokens to return:

string $method The request method:

int|null $start The start date to search from:

int|null $end The end date to search to:

Return value

array An array of tokens

Overrides ProfilerStorageInterface::find

File

vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php, line 52

Class

FileProfilerStorage
Storage for profiler using files.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

public function find($ip, $url, $limit, $method, $start = null, $end = null) {
  $file = $this
    ->getIndexFilename();
  if (!file_exists($file)) {
    return array();
  }
  $file = fopen($file, 'r');
  fseek($file, 0, SEEK_END);
  $result = array();
  while (count($result) < $limit && ($line = $this
    ->readLineFromFile($file))) {
    $values = str_getcsv($line);
    list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = $values;
    $csvStatusCode = isset($values[6]) ? $values[6] : null;
    $csvTime = (int) $csvTime;
    if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method)) {
      continue;
    }
    if (!empty($start) && $csvTime < $start) {
      continue;
    }
    if (!empty($end) && $csvTime > $end) {
      continue;
    }
    $result[$csvToken] = array(
      'token' => $csvToken,
      'ip' => $csvIp,
      'method' => $csvMethod,
      'url' => $csvUrl,
      'time' => $csvTime,
      'parent' => $csvParent,
      'status_code' => $csvStatusCode,
    );
  }
  fclose($file);
  return array_values($result);
}