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

diego-ninja / granite / 16608963009

29 Jul 2025 10:37PM UTC coverage: 50.423%. First build
16608963009

Pull #5

github

web-flow
Merge 43d8840d7 into 6a6caca51
Pull Request #5: code: adds phpstan level max, pint with per and github actions

321 of 632 new or added lines in 77 files covered. (50.79%)

1132 of 2245 relevant lines covered (50.42%)

9.88 hits per line

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

0.0
/src/Mapping/Transformers/DateTimeTransformer.php
1
<?php
2

3
namespace Ninja\Granite\Mapping\Transformers;
4

5
use DateTimeImmutable;
6
use DateTimeInterface;
7
use Exception;
8
use Ninja\Granite\Mapping\Contracts\Transformer;
9

10
final readonly class DateTimeTransformer implements Transformer
11
{
12
    public function __construct(
×
13
        private string $format = DateTimeInterface::ATOM,
14
    ) {}
×
15

16
    public function transform(mixed $value, array $sourceData = []): mixed
×
17
    {
NEW
18
        if (null === $value) {
×
19
            return null;
×
20
        }
21

22
        if ($value instanceof DateTimeInterface) {
×
23
            return $value;
×
24
        }
25

26
        if (is_string($value)) {
×
27
            try {
28
                return new DateTimeImmutable($value);
×
NEW
29
            } catch (Exception $e) {
×
30
                return null;
×
31
            }
32
        }
33

34
        return $value;
×
35
    }
36

37
    /**
38
     * Get the format used for parsing.
39
     *
40
     * @return string Date format
41
     */
NEW
42
    public function getFormat(): string
×
43
    {
NEW
44
        return $this->format;
×
45
    }
46
}
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