mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-05-07 20:32:26 +00:00
46 lines
1.5 KiB
PHP
46 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Enums;
|
|
|
|
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
|
|
enum TimeEntryAggregationType: string
|
|
{
|
|
use LaravelEnumHelper;
|
|
|
|
case Day = 'day';
|
|
case Week = 'week';
|
|
case Month = 'month';
|
|
case Year = 'year';
|
|
case User = 'user';
|
|
case Project = 'project';
|
|
case Task = 'task';
|
|
case Client = 'client';
|
|
case Billable = 'billable';
|
|
case Description = 'description';
|
|
case Tag = 'tag';
|
|
|
|
public static function fromInterval(TimeEntryAggregationTypeInterval $timeEntryAggregationTypeInterval): TimeEntryAggregationType
|
|
{
|
|
return match ($timeEntryAggregationTypeInterval) {
|
|
TimeEntryAggregationTypeInterval::Day => TimeEntryAggregationType::Day,
|
|
TimeEntryAggregationTypeInterval::Week => TimeEntryAggregationType::Week,
|
|
TimeEntryAggregationTypeInterval::Month => TimeEntryAggregationType::Month,
|
|
TimeEntryAggregationTypeInterval::Year => TimeEntryAggregationType::Year,
|
|
};
|
|
}
|
|
|
|
public function toInterval(): ?TimeEntryAggregationTypeInterval
|
|
{
|
|
return match ($this) {
|
|
TimeEntryAggregationType::Day => TimeEntryAggregationTypeInterval::Day,
|
|
TimeEntryAggregationType::Week => TimeEntryAggregationTypeInterval::Week,
|
|
TimeEntryAggregationType::Month => TimeEntryAggregationTypeInterval::Month,
|
|
TimeEntryAggregationType::Year => TimeEntryAggregationTypeInterval::Year,
|
|
default => null
|
|
};
|
|
}
|
|
}
|