File size: 1,340 Bytes
9304daa | 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 | <?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\Plugins\Bandwidth\Columns\Metrics;
use Piwik\DataTable\Row;
use Piwik\Metrics\Formatter;
use Piwik\Piwik;
use Piwik\Columns\Dimension;
use Piwik\Plugin\ProcessedMetric;
/**
* The total amount bandwidth used.
*
* Note: This Metric should actually inherit from AggregatedMetric class, but we need to use ProcessedMetric as core
* won't format the values automatically otherwise
*/
class OverallBandwidth extends ProcessedMetric
{
public function getName()
{
return 'nb_total_overall_bandwidth';
}
public function getDependentMetrics()
{
return [
$this->getName()
];
}
public function compute(Row $row)
{
return $row->getColumn($this->getName());
}
public function getTranslatedName()
{
return Piwik::translate('Bandwidth_ColumnTotalOverallBandwidth');
}
public function format($value, Formatter $formatter)
{
if ($value) {
$value = $formatter->getPrettySizeFromBytes($value, null, 2);
}
return $value;
}
public function getSemanticType(): ?string
{
return Dimension::TYPE_NUMBER;
}
}
|