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

tempestphp / tempest-framework / 14024978163

23 Mar 2025 05:55PM UTC coverage: 79.391% (-0.05%) from 79.441%
14024978163

push

github

web-flow
feat(view): cache Blade and Twig templates in internal storage (#1061)

2 of 2 new or added lines in 2 files covered. (100.0%)

912 existing lines in 110 files now uncovered.

10478 of 13198 relevant lines covered (79.39%)

91.09 hits per line

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

95.83
/src/Tempest/Mapper/src/Mappers/ObjectToArrayMapper.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Mapper\Mappers;
6

7
use JsonSerializable;
8
use Tempest\Mapper\Mapper;
9
use Tempest\Mapper\MapTo;
10
use Tempest\Mapper\SerializerFactory;
11
use Tempest\Reflection\ClassReflector;
12
use Tempest\Reflection\PropertyReflector;
13

14
final readonly class ObjectToArrayMapper implements Mapper
15
{
16
    public function __construct(
129✔
17
        private SerializerFactory $serializerFactory,
18
    ) {
19
    }
129✔
20

21
    public function canMap(mixed $from, mixed $to): bool
122✔
22
    {
23
        return false;
122✔
24
    }
25

26
    public function map(mixed $from, mixed $to): array
7✔
27
    {
28
        if ($from instanceof JsonSerializable) {
7✔
29
            return $from->jsonSerialize();
1✔
30
        }
31

32
        $class = new ClassReflector($from);
6✔
33

34
        $mappedProperties = [];
6✔
35

36
        foreach ($class->getPublicProperties() as $property) {
6✔
37
            $propertyName = $this->resolvePropertyName($property);
6✔
38
            $propertyValue = $this->resolvePropertyValue($property, $from);
6✔
39
            $mappedProperties[$propertyName] = $propertyValue;
6✔
40
        }
41

42
        return $mappedProperties;
6✔
43
    }
44

45
    private function resolvePropertyValue(PropertyReflector $property, object $object): mixed
6✔
46
    {
47
        $propertyValue = $property->getValue($object);
6✔
48

49
        if (($serializer = $this->serializerFactory->forProperty($property)) !== null) {
6✔
50
            return $serializer->serialize($propertyValue);
6✔
51
        }
52

UNCOV
53
        return $propertyValue;
×
54
    }
55

56
    private function resolvePropertyName(PropertyReflector $property): string
6✔
57
    {
58
        $mapTo = $property->getAttribute(MapTo::class);
6✔
59

60
        if ($mapTo !== null) {
6✔
61
            return $mapTo->name;
2✔
62
        }
63

64
        return $property->getName();
5✔
65
    }
66
}
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