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

plank / laravel-metable / 8730412986

18 Apr 2024 12:20AM UTC coverage: 90.887% (-7.9%) from 98.76%
8730412986

Pull #102

github

web-flow
Merge pull request #101 from anilkumarthakur60/v6

V6 migration and ci fixes
Pull Request #102: V6

185 of 222 new or added lines in 16 files covered. (83.33%)

26 existing lines in 7 files now uncovered.

369 of 406 relevant lines covered (90.89%)

64.39 hits per line

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

90.91
/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
    const FORMAT = 'Y-m-d H:i:s.uO';
19

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

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

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

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

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

59
    public function getStringValue(mixed $value): null|string
60
    {
61
        return $value instanceof DateTimeInterface
24✔
62
            ? $value->copy()->setTimezone('UTC')->format(self::FORMAT)
24✔
63
            : null;
24✔
64
    }
65

66
    public function isIdempotent(): bool
67
    {
NEW
UNCOV
68
        return true;
×
69
    }
70
}
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

© 2026 Coveralls, Inc