Lines 77.77% 7 / 9
Methods 50.00% 1 / 2
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 formatDateArray 100.00% 5 / 5 100.00% 1 / 1 1
 getInternalDateFromTimestamp 50.00% 2 / 4 0.00% 0 / 1 2.50
7class DateTimeFormatHelper
8{
9    private static function formatDateArray(\DateTime $date): array
10    {
11        return [
12            'day' => (int) $date->format('d'),
13            'month' => (int) $date->format('m'),
14            'year' => (int) $date->format('Y'),
15        ];
16    }
17
18    public static function getInternalDateFromTimestamp(int $timestamp): array
19    {
20        try {
21            $date = (new \DateTime())->setTimestamp($timestamp);
22            return self::formatDateArray($date);
23        } catch (\Exception $e) {
24            throw new \InvalidArgumentException('Invalid timestamp: ' . $e->getMessage());
25        }
26    }
27}