Returns given job progress
@param  string $job id
@param  string $format format to output data
@return array
548174
public static function getProgress($job, $format = null)
    {
        // Get the temporary directory
        $tmpdir = self::getTempPath();

        // The code below has been adapted from Jimbo
        // http://stackoverflow.com/questions/11441517/ffmpeg-progress-bar-encoding-percentage-in-php
        $content = @file_get_contents($tmpdir.$job.'.sonustmp');

        if($content)
        {
            // Get duration of source
            preg_match("/Duration: (.*?), start:/", $content, $matches);

            $rawDuration = $matches[1];

            // rawDuration is in 00:00:00.00 format. This converts it to seconds.
            $ar = array_reverse(explode(":", $rawDuration));
            $duration = floatval($ar[0]);
            if (!empty($ar[1])) $duration += intval($ar[1]) * 60;
            if (!empty($ar[2])) $duration += intval($ar[2]) * 60 * 60;

            // Get the time in the file that is already encoded
            preg_match_all("/time=(.*?) bitrate/", $content, $matches);

            $rawTime = array_pop($matches);

            // This is needed if there is more than one match
            if (is_array($rawTime))
            {
                $rawTime = array_pop($rawTime);
            }

            // rawTime is in 00:00:00.00 format. This converts it to seconds.
            $ar = array_reverse(explode(":", $rawTime));
            $time = floatval($ar[0]);
            if (!empty($ar[1])) $time += intval($ar[1]) * 60;
            if (!empty($ar[2])) $time += intval($ar[2]) * 60 * 60;

            // Calculate the progress
            $progress = round(($time/$duration) * 100);

            // Output to array
            $output = array(
                'Duration' => $rawDuration,
                'Current'  => $rawTime,
                'Progress' => $progress
                );

            // Return data
            switch ($format) 
            {
                case 'array':
                    return $output;
                    break;
                
                default:
                    return json_encode($output);
                    break;
            }
        } else {
            return null;
        }
    }
1226908
private function getJobIdsOfIncomingDependencies(Job $job)
    {
        $jobIds = $this->_em->getConnection()
            ->executeQuery('SELECT source_job_id FROM jms_job_dependencies WHERE dest_job_id = :id', ['id' => $job->getId()])
            ->fetchAll(\PDO::FETCH_COLUMN);

        return $jobIds;
    }
1162370
public function convertId($id, $format = null)
    {
        $this->convertToAll($id);

        switch ($format) {
            case 'ID32':
            case 'id32':
            case 32:
                return $this->formatted->{self::$ID32};
            case 'ID64':
            case 'id64':
            case 64:
                return $this->formatted->{self::$ID64};
            case 'ID3':
            case 'id3':
            case 3:
                return $this->formatted->{self::$ID3};
            default:
                return $this->formatted;
        }
    }
1219864
protected function extractFormat($source, $target, FormatInterface $format)
    {
        $success = false;
        for ($i = 0, $methodsCount = count($this->methods); $i<$methodsCount && false === $success; $i++) {
            $method = $this->methods[$i];

            if ($method->isSupported() && $method->isFormatSupported($format)) {
                $success = $method->extract($source, $target, $format);
            }
        }

        return $success;
    }
261818
private function parseDates($data, $format)
    {
        foreach ($data as $key => $entry) {
            $data[$key]['date'] = $data[$key]['date']->format($format);
        }

        return $data;
    }
787531
public function output($format = 'json', $force = false)
	{
		// generate output
		if ($force || !$this->cache())
		{
			$this->generate();
		}

		// option to switch formats
		switch ($format)
		{
			case 'array':
				break;
			case 'php':
				$this->output = serialize($this->output);
				break;
			case 'json':
			default:
				$this->output = json_encode($this->output);
		}

		return $this->output;
	}
1205076
public function getElapsedTime($format = false)
    {
      $elapsed = microtime(true) - $this->startTime;

      if ($format && $elapsed >= 1) {
          $elapsed = gmdate("H:i:s", $elapsed);
      }

      return $elapsed;
    }
1072826
public function get($format)
    {
        if ('plain' == $format || 'string' == $format) {
            return $this->makePlain();
        }
        if ('json' == $format) {
            return $this->makeJson();
        }

        return json_decode($this->response, true);
    }
1218346
public function getFormattedDate($format, $startDate = true)
    {
        $date = $this->getEndDate();

        // Start date should be formatted?
        if ($startDate) {
            $date = $this->getStartDate();
        }

        // Unknown date or format is invalid?
        // Nothing to do
        if (null === $date || !Date::isValidDateFormat($format)) {
            return '';
        }

        return $date->format($format);
    }
465641
public function writeOutput($job, $status)
    {
        switch ($status) {
        case 'starting':
            return $this->writeStatus($job, 'Processing', 'comment');
        case 'success':
            return $this->writeStatus($job, 'Processed', 'info');
        case 'failed':
            return $this->writeStatus($job, 'Failed', 'error');
        }
    }
864895
public function getEnqueuedDate($format = null)
    {
        $node = $this->getFirst('//epp:epp/epp:response/epp:msgQ/epp:qDate');
        if ($node === null) {
            return null;
        }

        if ($format === null) {
            return $node->nodeValue;
        }

        return date_create_from_format($format, $node->nodeValue);
    }
938543
public function findService($format, $methods)
    {

        $found = false;
        $services = $this->consumer->profile->service_offered;
        if (is_array($services)) {
            $n = -1;
            foreach ($services as $service) {
                $n++;
                if (!is_array($service->format) || !in_array($format, $service->format)) {
                    continue;
                }
                $missing = array();
                foreach ($methods as $method) {
                    if (!is_array($service->action) || !in_array($method, $service->action)) {
                        $missing[] = $method;
                    }
                }
                $methods = $missing;
                if (count($methods) <= 0) {
                    $found = $service;
                    break;
                }
            }
        }

        return $found;

    }
24355
public function log($format = null) {
		if ($format === null)
			return $this->run('log');
		else
			return $this->run('log --pretty=format:"' . $format . '"');
	}
429807
@Override
  protected Response jobInProgress(final Job job, final Key dst) {
    progress = job.progress();
    return Response.poll(this, (int) (100 * progress), 100, "job_key", job_key.toString(), "destination_key",
        destination_key.toString());
  }
203081
public function checkAsynchronousProcessingStatus($jobId, $processId)
    {
        $endpoint = vsprintf('jobs/%s/processes/%s', [$jobId, $processId]);
        $requestData = $this->getDefaultRequestData('query', []);

        return $this->sendRequest($endpoint, $requestData, self::HTTP_METHOD_GET);
    }
623018
public function getByFormat($format)
    {
        foreach ($this->getExporters() as $exporter) {
            if ($exporter->support($format)) {
                return $exporter;
            }
        }

        throw new \RuntimeException(sprintf('No exporter found for "%s" format.', $format));
    }
324416
public function getDataCredito($format = 'd/m/Y')
    {
        return $this->dataCredito instanceof Carbon
        ? $format === false ? $this->dataCredito : $this->dataCredito->format($format)
        : null;
    }