• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

plank / laravel-metable / 12172137688

05 Dec 2024 02:34AM UTC coverage: 99.535%. Remained the same
12172137688

push

github

web-flow
Merge pull request #111 from plank/php-84

Add PHP 8.4 support

642 of 645 relevant lines covered (99.53%)

191.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/DataType/DateTimeHandler.php
1
<?php
2

3
namespace Plank\Metable\DataType;
4

5
use Carbon\Carbon;
6
use DateTimeInterface;
7

8
/**
9
 * Handle serialization of DateTimeInterface objects.
10
 */
11
class DateTimeHandler implements HandlerInterface
12
{
13
    /**
14
     * The date format to use for serializing.
15
     *
16
     * @var string
17
     */
18
    public const FORMAT = 'Y-m-d H:i:s.uO';
19

20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getDataType(): string
24
    {
25
        return 'datetime';
900✔
26
    }
27

28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function canHandleValue(mixed $value): bool
32
    {
33
        return $value instanceof DateTimeInterface;
228✔
34
    }
35

36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function serializeValue(mixed $value): string
40
    {
41
        return $value->format(self::FORMAT);
84✔
42
    }
43

44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function unserializeValue(string $serializedValue): mixed
48
    {
49
        return Carbon::createFromFormat(self::FORMAT, $serializedValue);
66✔
50
    }
51

52
    public function getNumericValue(mixed $value): null|int|float
53
    {
54
        return $value instanceof DateTimeInterface
84✔
55
            ? $value->getTimestamp()
84✔
56
            : null;
84✔
57
    }
58

59
    public function useHmacVerification(): bool
60
    {
61
        return false;
84✔
62
    }
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc