# metricool/2.1.1/app/Http/Metricool/DTOs/DistributionDTO.php

Metricool – Social media and site statistics, version 2.1.1. 36 lines.

- Page: https://pluginprobe.com/plugins/metricool/2.1.1/code/app/Http/Metricool/DTOs/DistributionDTO.php
- Raw: https://pluginprobe.com/plugins/metricool/2.1.1/raw/app/Http/Metricool/DTOs/DistributionDTO.php
- Modified: 2026-08-20T14:08:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/metricool/2.1.1/code/app/Http/Metricool/DTOs/DistributionDTO.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace Metricool\Http\Metricool\DTOs;

/**
 * This class represents a DistributionDTO of one of the results of
 * the DistributionDTO Entity.
 */
class DistributionDTO extends DTO
{
    public string $name;
    public string $value;
    public int $amount;

    public function __construct(string $name, string $value, int $amount)
    {
        $this->name = $name;
        $this->value = $value;
        $this->amount = $amount;
    }

    /**
     * Calculates the percentage of the amount in relation to the total number
     * @see \Metricool\Http\Endpoints\Responses\Statistics\CountriesResponse::getSingleItem()
     */
    public function calculatePercentageFromTotal(int $total): float
    {
        if ($total === 0 || $this->amount === 0) {
            return 0;
        }
        return round((float) (($this->amount / $total) * 100), 3, PHP_ROUND_HALF_UP);
    }
}

```
