Lookup a statistic.

@param int    $time
@param string $name

@return array
196681
protected function stat($time, $name)
    {
        $stats = $this->get('stats', ['interval' => $time], (string) $time);

        return array_get($stats, 'response.result.objs.0.'.$name);
    }
271351
private function getIndexByNameAndDate($name, DateTime $dateTime)
    {
        $timestamp = $dateTime->getTimestamp();
        foreach ($this->holidayList as $index => $holiday) {
            if ($name === $holiday->getName() && $timestamp === $holiday->getTimestamp()) {
                return $index;
            }
        }

        return -1;
    }
185026
public function getFieldAsArray(string $name): array
    {
        $result = $this->getFieldDefinition($name);

        $result['name'] = $name;

        if (empty($result['caption'])) {
            $result['caption'] = $this->_($result['name']);
        }

        $value = $this->$name;
        $type = @$result['type'];

        if (($type == 'date' || $type == 'datetime' || $type == 'time') && is_object($value)) {
            $value = $value->format($this->translate('form.' . $type));
        }

        $result['value'] = $value;
        $result['uid'] = 'id' . uniqid();

        if (isset($result['options']) && is_array($result['options'])) {
            $options = array();

            foreach ($result['options'] as $option => $label) {
                $options[] = array('option' => $option, 'label' => $label);
            }

            $result['options'] = $options;
        }

        return $result;
    }
204650
public function addStatistics($path, $time)
    {
        if (!array_key_exists($path, $this->statisticsMap)) {
            $this->statisticsMap[$path]['times'] = 0;
            $this->statisticsMap[$path]['used'] = 0;
            $this->statisticsMap[$path]['min'] = 9999999;
            $this->statisticsMap[$path]['max'] = 0;
        }
        $this->statisticsMap[$path]['times']++;
        $this->statisticsMap[$path]['used'] += $time;
        if ($time < $this->statisticsMap[$path]['min']) {
            $this->statisticsMap[$path]['min'] = $time;
        }
        if ($time > $this->statisticsMap[$path]['max']) {
            $this->statisticsMap[$path]['max'] = $time;
        }
    }
962411
public function isFresh($name, $time)
    {
        $file = $this->findTemplateFile($name);
        $fresh = (filemtime($file) <= $time);
        return $fresh;
    }
933089
public function getTime($time = self::TIME_MODIFIED)
    {
        $result = false;
        $info = $this->getInfo();

        if(isset($info[$time])) {
            $result = new \DateTime('@'.$info[$time]);
        }

        return $result;
    }
1069493
private function getFormTime(string $name): ?DateTime
    {
        $key = $this->getSessionKey($name);

        if ($this->hasFormProtection($name)) {
            return $this->session->get($key);
        }

        return null;
    }
389896
public function get(DateTime $datetime, $name)
	{
		$value = null;

		switch ($name)
		{
			case 'daysinmonth':
				$value = $datetime->format('t');
				break;

			case 'dayofweek':
				$value = $datetime->format('N');
				break;

			case 'dayofyear':
				$value = $datetime->format('z');
				break;

			case 'isleapyear':
				$value = (boolean) $datetime->format('L');
				break;

			case 'day':
				$value = $datetime->format('d');
				break;

			case 'hour':
				$value = $datetime->format('H');
				break;

			case 'minute':
				$value = $datetime->format('i');
				break;

			case 'second':
				$value = $datetime->format('s');
				break;

			case 'month':
				$value = $datetime->format('m');
				break;

			case 'ordinal':
				$value = $datetime->format('S');
				break;

			case 'week':
				$value = $datetime->format('W');
				break;

			case 'year':
				$value = $datetime->format('Y');
				break;

			default:
				$trace = debug_backtrace();
				trigger_error('Undefined property: ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
		}

		return $value;
	}
331871
protected function getMeta(string $name = null): array
    {
        return self::query($this->db->createDesc($name ? $name : $this->tableName));
    }
1260923
public function getValues($name)
    {
        $return = [];
        $items  = $this->getItems();

        foreach ($items as $type) {
            $method = 'get' . ucfirst($name);
            if (method_exists($type, $method)) {
                $return[] = $type->$method();
            } else {
                $return[] = $type->{$name};
            }
        }

        return $return;
    }
48389
public static function timeStamp($time)
    {
        $different = time() - $time;

        $seconds = $different;
        $minutes = round($different / 60);
        $hours = round($different / 3600);
        $days = round($different / 86400);
        $weeks = round($different / 604800);
        $months = round($different / 2419200);
        $years = round($different / 29030400);

        //Second
        if ($seconds <= 60) {
            if ($seconds == 1) {
                return "$seconds second ago";
            } else {
                return "$seconds seconds ago";
            }
        }

        //Minutes
        elseif ($minutes <= 60) {
            if ($minutes == 1) {
                return "$minutes minute ago";
            } else {
                return "$minutes minutes ago";
            }
        }

        //Hours
        elseif ($hours <= 24) {
            if ($hours == 1) {
                return "$hours hour ago";
            } else {
                return "$hours hours ago";
            }
        }

        //Days
        elseif ($days <= 7) {
            if ($days = 1) {
                return "$days day ago";
            } else {
                return "$days days ago";
            }
        }

        //Weeks
        elseif ($weeks <= 4) {
            if ($weeks == 1) {
                return "$weeks week ago";
            } else {
                return "$weeks weeks ago";
            }
        }

        //Months
        elseif ($months <= 12) {
            if ($months == 1) {
                return "$months month ago";
            } else {
                return "$months months ago";
            }
        }

        //Years
        else {
            if ($years == 1) {
                return "$years year ago";
            } else {
                return "$years years ago";
            }
        }
    }
1321187
public function find($name)
	{
		$hztp = new self();

		if (is_numeric($name))
		{
			$hztp->id = $name;
		}
		else
		{
			$hztp->name = $name;
		}

		if ($hztp->read() == false)
		{
			return false;
		}

		return $hztp;
	}
112769
public function jsonCacheStart( $name, $language = '', $cache_timer=900 ) 
	{
		$cache_folder = $this->app->config('cache.path')."/json/";
		$cache_name   = md5($name.$language).".json";
	
		$ntime = strtotime( date("Y-m-d H:i:s") );
		$ftime = @filemtime( $cache_folder.$cache_name );
	
		$product = $ntime-$ftime;
	
		if((int)$cache_timer > (int)$product && $ftime!=false ) {   // 100 <17 //
			return json_decode( $this->jsonCacheUnCompress( file_get_contents( $cache_folder.$cache_name ) ), true ); // returns array in the event cache data is to be used
		} else {
			return true; // returns true in the event that the timer has expired
		}
	}
1237649
public static function benchmark(string $name = '') {
		if (self::$debug) {
			static $start = NULL;
			static $total = 0;
			$benchmark = 0;
			if (is_null($start)) {
				$start = self::getMicrotime();
			} else {
				$temp = self::getMicrotime();
				$benchmark = $temp - $start;
				$start = $temp;
			}
			$total+= $benchmark;
			self::$data['benchmark'][] = [
				'name' => $name,
				'time' => \Format::timeSeconds($benchmark) . '',
				'total' => \Format::timeSeconds($total),
				'start' => \Format::datetime($start, ['skip_user_timezone' => true]),
				'memory' => memory_get_peak_usage(true)
			];
		}
	}
212707
public function getArguments($name)
    {
        if (null === $this->data) {
            $this->initializeProfile();
        }

        if (!isset($this->data['arguments'][$name])) {
            return array();
        }

        $arguments = array();
        foreach ($this->data['arguments'][$name] as $argument => $cost) {
            $arguments[$argument] = new Cost($cost);
        }

        return $arguments;
    }
478081
private function getStatValue($name)
    {
        if (isset($this->_extra[self::ENTRY_STATS][$name])) {
            return $this->_extra[self::ENTRY_STATS][$name];
        }

        return 0;
    }
217234
public function run($time = null) {

		if(empty($this->jobs)) return;

		if($time === null) $time = time();
		$date = getdate($time);

		$count = 0;

		foreach($this->jobs as $job) {
			$result = $job->run($date);
			if($result) $count++;
		}

		return $count;

	}