Dimension
6 years ago
API.php
6 years ago
AggregatedMetric.php
6 years ago
ArchivedMetric.php
6 years ago
Archiver.php
6 years ago
Categories.php
6 years ago
ComponentFactory.php
6 years ago
ComputedMetric.php
6 years ago
ConsoleCommand.php
6 years ago
Controller.php
6 years ago
ControllerAdmin.php
6 years ago
Dependency.php
6 years ago
LogTablesProvider.php
6 years ago
Manager.php
6 years ago
Menu.php
6 years ago
MetadataLoader.php
6 years ago
Metric.php
6 years ago
PluginException.php
6 years ago
ProcessedMetric.php
6 years ago
ReleaseChannels.php
6 years ago
Report.php
6 years ago
ReportsProvider.php
6 years ago
RequestProcessors.php
6 years ago
Segment.php
6 years ago
SettingsProvider.php
6 years ago
Tasks.php
6 years ago
ThemeStyles.php
6 years ago
ViewDataTable.php
6 years ago
Visualization.php
6 years ago
WidgetsProvider.php
6 years ago
ProcessedMetric.php
89 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Piwik - free/libre analytics platform |
| 4 | * |
| 5 | * @link https://matomo.org |
| 6 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 7 | */ |
| 8 | namespace Piwik\Plugin; |
| 9 | |
| 10 | use Piwik\DataTable; |
| 11 | use Piwik\DataTable\Row; |
| 12 | |
| 13 | /** |
| 14 | * Base type for processed metrics. A processed metric is a metric that is computed using |
| 15 | * one or more other metrics. |
| 16 | * |
| 17 | * @api |
| 18 | */ |
| 19 | abstract class ProcessedMetric extends Metric |
| 20 | { |
| 21 | /** |
| 22 | * The sub-namespace name in a plugin where ProcessedMetrics are stored. |
| 23 | */ |
| 24 | const COMPONENT_SUBNAMESPACE = 'Columns\\Metrics'; |
| 25 | |
| 26 | /** |
| 27 | * Computes the metric using the values in a {@link Piwik\DataTable\Row}. |
| 28 | * |
| 29 | * The computed value should be numerical and not formatted in any way. For example, for |
| 30 | * a percent value, `0.14` should be returned instead of `"14%"`. |
| 31 | * |
| 32 | * @return mixed |
| 33 | */ |
| 34 | abstract public function compute(Row $row); |
| 35 | |
| 36 | /** |
| 37 | * Returns the array of metrics that are necessary for computing this metric. The elements |
| 38 | * of the array are metric names. |
| 39 | * |
| 40 | * @return string[] |
| 41 | */ |
| 42 | abstract public function getDependentMetrics(); |
| 43 | |
| 44 | /** |
| 45 | * Returns the array of metrics that are necessary for computing this metric, but should not |
| 46 | * be displayed to the user unless explicitly requested. These metrics are intermediate |
| 47 | * metrics that are not really valuable to the user. On a request, if showColumns or hideColumns |
| 48 | * is not used, they will be removed automatically. |
| 49 | * |
| 50 | * @return string[] |
| 51 | */ |
| 52 | public function getTemporaryMetrics() |
| 53 | { |
| 54 | return array(); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Executed before computing all processed metrics for a report. Implementers can return `false` |
| 59 | * to skip computing this metric. |
| 60 | * |
| 61 | * @param Report $report |
| 62 | * @param DataTable $table |
| 63 | * @return bool Return `true` to compute the metric for the table, `false` to skip computing |
| 64 | * this metric. |
| 65 | */ |
| 66 | public function beforeCompute($report, DataTable $table) |
| 67 | { |
| 68 | return true; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * @param Row $row |
| 73 | * @ignore |
| 74 | */ |
| 75 | public function beforeComputeSubtable(Row $row) |
| 76 | { |
| 77 | // empty |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @param Row $row |
| 82 | * @ignore |
| 83 | */ |
| 84 | public function afterComputeSubtable(Row $row) |
| 85 | { |
| 86 | // empty |
| 87 | } |
| 88 | } |
| 89 |