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

DerManoMann / json-object-mapper / 3868897722

pending completion
3868897722

push

github

GitHub
Merge pull request #33 from DerManoMann/refresh

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

71.43
/src/TypeReference/TypeReferenceFactory.php
1
<?php
2

3
declare(strict_types=1);
4

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

14
namespace Radebatz\ObjectMapper\TypeReference;
15

16
use Radebatz\ObjectMapper\ObjectMapperException;
17
use Symfony\Component\PropertyInfo\Type;
18

19
class TypeReferenceFactory
20
{
21
    public static function getTypeReferenceForType(Type $type)
22
    {
23
        if ($className = $type->getClassName()) {
63✔
24
            return new ClassTypeReference($className, $type->isNullable());
47✔
25
        }
26

27
        if ($buildInType = $type->getBuiltinType()) {
56✔
28
            switch ($buildInType) {
29
                case Type::BUILTIN_TYPE_ARRAY:
30
                    // TODO: collection key type
31
                    return new CollectionTypeReference(self::getTypeReferenceForType($type->getCollectionValueType()), null, $type->isNullable());
36✔
32

33
                case Type::BUILTIN_TYPE_INT:
34
                case Type::BUILTIN_TYPE_FLOAT:
35
                case Type::BUILTIN_TYPE_STRING:
36
                case Type::BUILTIN_TYPE_BOOL:
37
                case Type::BUILTIN_TYPE_NULL:
38
                    return new ScalarTypeReference($buildInType, $type->isNullable());
55✔
39

40
                case Type::BUILTIN_TYPE_CALLABLE:
41
                case Type::BUILTIN_TYPE_RESOURCE:
42
                case Type::BUILTIN_TYPE_ITERABLE:
43
                    throw new ObjectMapperException(sprintf('Invalid value type: %s', $buildInType));
×
44
            }
45
        }
46

47
        return null;
×
48
    }
49
}
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