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

plank / laravel-metable / 8731108978

18 Apr 2024 01:38AM UTC coverage: 92.361% (-6.4%) from 98.76%
8731108978

Pull #102

github

frasmage
added metable:refresh artisan command
Pull Request #102: V6

215 of 248 new or added lines in 18 files covered. (86.69%)

26 existing lines in 7 files now uncovered.

399 of 432 relevant lines covered (92.36%)

65.06 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';
282✔
26
    }
27

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

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

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

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

59
    public function getStringValue(mixed $value): null|string
60
    {
61
        return $value instanceof DateTimeInterface
30✔
62
            ? $value->copy()->setTimezone('UTC')->format(self::FORMAT)
30✔
63
            : null;
30✔
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

© 2025 Coveralls, Inc