<?php
namespace Ceetrox\Managers\ChartManager;

use Illuminate\Support\Collection;

class Series extends Collection
{
    public function toArray(): array
    {
        $return = [];
        $this->each(function (SeriesData $entry) use (&$return) {
            $return[] = $entry->toArray();
        });

        return $return;
    }

    public function numberOfCharts(): int
    {
        return $this->unique(function (SeriesData $entry) {
           return $entry->getIndex();
        })->count();
    }
}
