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