<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Event\Sourcing\Versioning;

final class EventVersioningStatistics
{
    public static function from(array $versions, array $upcasters, array $results): array
    {
        $upcasted = 0;
        foreach ($results as $result) {
            if (($result['upcasted'] ?? false) === true) { $upcasted++; }
        }

        return ['versions' => count($versions), 'upcasters' => count($upcasters), 'results' => count($results), 'upcasted' => $upcasted, 'unchanged' => count($results) - $upcasted];
    }
}
