Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ProcessedMetric.php « Plugin « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec5e7403f036e4d4aca0fee6350a2eb64e5b0297 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
 * Matomo - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 */
namespace Piwik\Plugin;

use Piwik\DataTable;
use Piwik\DataTable\Row;

/**
 * Base type for processed metrics. A processed metric is a metric that is computed using
 * one or more other metrics.
 *
 * @api
 */
abstract class ProcessedMetric extends Metric
{
    /**
     * The sub-namespace name in a plugin where ProcessedMetrics are stored.
     */
    const COMPONENT_SUBNAMESPACE = 'Columns\\Metrics';

    /**
     * Computes the metric using the values in a {@link Piwik\DataTable\Row}.
     *
     * The computed value should be numerical and not formatted in any way. For example, for
     * a percent value, `0.14` should be returned instead of `"14%"`.
     *
     * @return mixed
     */
    abstract public function compute(Row $row);

    /**
     * Returns the array of metrics that are necessary for computing this metric. The elements
     * of the array are metric names.
     *
     * @return string[]
     */
    abstract public function getDependentMetrics();

    /**
     * Returns the array of metrics that are necessary for computing this metric, but should not
     * be displayed to the user unless explicitly requested. These metrics are intermediate
     * metrics that are not really valuable to the user. On a request, if showColumns or hideColumns
     * is not used, they will be removed automatically.
     *
     * @return string[]
     */
    public function getTemporaryMetrics()
    {
        return array();
    }

    /**
     * Executed before computing all processed metrics for a report. Implementers can return `false`
     * to skip computing this metric.
     *
     * @param Report $report
     * @param DataTable $table
     * @return bool Return `true` to compute the metric for the table, `false` to skip computing
     *              this metric.
     */
    public function beforeCompute($report, DataTable $table)
    {
        return true;
    }

    /**
     * @param Row $row
     * @ignore
     */
    public function beforeComputeSubtable(Row $row)
    {
        // empty
    }

    /**
     * @param Row $row
     * @ignore
     */
    public function afterComputeSubtable(Row $row)
    {
        // empty
    }
}