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

DerManoMann / json-object-mapper / 10778033527

09 Sep 2024 05:16PM UTC coverage: 87.286%. Remained the same
10778033527

Pull #35

github

web-flow
Merge eab15aadb into 82479c6e8
Pull Request #35: Update netresearch/jsonmapper requirement from ^3.0 || ^4.0 to ^3.0 || ^4.0 || ^5.0

357 of 409 relevant lines covered (87.29%)

33.96 hits per line

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

80.0
/src/TypeMapper/DateTimeTypeMapper.php
1
<?php declare(strict_types=1);
2

3
/*
4
* This file is part of the ObjectMapper library.
5
*
6
* (c) Martin Rademacher <mano@radebatz.net>
7
*
8
* For the full copyright and license information, please view the LICENSE
9
* file that was distributed with this source code.
10
*/
11

12
namespace Radebatz\ObjectMapper\TypeMapper;
13

14
use Radebatz\ObjectMapper\TypeReferenceInterface;
15

16
/**
17
 * Maps single values onto `\DateTime` instance.
18
 */
19
class DateTimeTypeMapper extends AbstractTypeMapper
20
{
21
    public function map($value, ?TypeReferenceInterface $typeReference = null, $key = null)
22
    {
23
        if (!is_scalar($value)) {
4✔
24
            throw new \InvalidArgumentException('Expecting scalar value');
×
25
        }
26

27
        if (is_numeric($value)) {
4✔
28
            $value = '@' . $value;
2✔
29
        }
30

31
        return new \DateTime($value);
4✔
32
    }
33
}
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