<?php
namespace Ceetrox\Managers\ChartManager;

use Illuminate\Support\Collection;

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

        return $return;
    }

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