• 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/DateTimeImmutableHandler.php
1
<?php
2

3
namespace Plank\Metable\DataType;
4

5
use Carbon\Carbon;
6
use Carbon\CarbonImmutable;
7
use DateTimeInterface;
8

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

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

29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function canHandleValue(mixed $value): bool
33
    {
34
        return $value instanceof \DateTimeImmutable;
270✔
35
    }
36

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

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

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

60
    public function useHmacVerification(): bool
61
    {
62
        return false;
54✔
63
    }
64
}
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