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

varhall / restino / 8143456103

04 Mar 2024 04:17PM UTC coverage: 94.805% (-0.5%) from 95.276%
8143456103

push

github

feropeterko
cleanup old classes

365 of 385 relevant lines covered (94.81%)

0.95 hits per line

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

94.44
/src/Mapping/MappingService.php
1
<?php
2

3
namespace Varhall\Restino\Mapping;
4

5
use Nette\Schema\Processor;
6
use Varhall\Restino\Controllers\RestRequest;
7
use Varhall\Utilino\Mapping\Target;
8

9
class MappingService
10
{
11
    public function process(Target $parameter, RestRequest $request): mixed
1✔
12
    {
13
        if ($parameter->getType()->getName() === RestRequest::class) {
1✔
14
            return $request;
1✔
15
        }
16

17
        $data = $request->getParameters();
1✔
18
        $value = $this->isClassType($parameter)
1✔
19
                    ? $data
1✔
20
                    : (array_key_exists($parameter->getName(), $data) ? $data[$parameter->getName()] : null);
1✔
21

22
        return (new Processor())->process($parameter->schema(), $value);
1✔
23
    }
24

25
    protected function isClassType(Target $parameter): bool
1✔
26
    {
27
        if (!$parameter->getType()) {
1✔
28
            return false;
×
29
        }
30

31
        $type = $parameter->getType()->getName();
1✔
32

33
        if (!class_exists($type)) {
1✔
34
            return false;
1✔
35
        }
36

37
        if ($type === \DateTime::class || is_subclass_of($type, \DateTime::class)) {
1✔
38
            return false;
1✔
39
        }
40

41
        return true;
1✔
42
    }
43
}
1✔
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