Everyone sees their open tasks on an agenda, their open jobs, this week's hours and quick links. Admin and management also get a lazily loaded management panel: things to do, the month so far against the previous month, jobs and late work, and everyone's workload. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
24 lines
567 B
PHP
24 lines
567 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Dashboard\Domain\ValueObjects;
|
|
|
|
/**
|
|
* How a figure changed from the comparison period: the ratio of the
|
|
* difference to the earlier value, or null when there was nothing to
|
|
* compare with (the earlier value was zero).
|
|
*/
|
|
final readonly class Change
|
|
{
|
|
public function __construct(
|
|
public int $current,
|
|
public int $previous,
|
|
) {}
|
|
|
|
public function ratio(): ?float
|
|
{
|
|
return $this->previous === 0 ? null : ($this->current - $this->previous) / abs($this->previous);
|
|
}
|
|
}
|