Test Failed
Push — master ( ed7d3a...1e1c10 )
by Dominik
02:15
created

app/services/validation.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiSkeleton;
6
7
use Chubbyphp\ApiSkeleton\Model\Document;
8
use Chubbyphp\ApiSkeleton\Validation\DocumentMapping;
9
use Chubbyphp\Model\Resolver;
10
use Chubbyphp\Validation\Mapping\LazyObjectMapping;
11
use Chubbyphp\Validation\Provider\ValidationProvider;
12
use Slim\Container;
13
use Chubbyphp\ApiSkeleton\Model\Course;
14
use Chubbyphp\ApiSkeleton\Search\CourseSearch;
15
use Chubbyphp\ApiSkeleton\Validation\CourseMapping;
16
use Chubbyphp\ApiSkeleton\Validation\CourseSearchMapping;
17
18
/* @var Container $container */
19
20
$container->register(new ValidationProvider());
21
22 View Code Duplication
$container->extend('validator.objectmappings', function (array $objectMappings) use ($container) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    $objectMappings[] = new LazyObjectMapping(
24
        $container,
25
        CourseMapping::class,
26
        Course::class
27
    );
28
29
    $objectMappings[] = new LazyObjectMapping(
30
        $container,
31
        CourseSearchMapping::class,
32
        CourseSearch::class
33
    );
34
35
    $objectMappings[] = new LazyObjectMapping(
36
        $container,
37
        DocumentMapping::class,
38
        Document::class
39
    );
40
41
    return $objectMappings;
42
});
43
44
$container[CourseMapping::class] = function () use ($container) {
45
    return new CourseMapping($container[Resolver::class]);
46
};
47
48
$container[CourseSearchMapping::class] = function () {
49
    return new CourseSearchMapping();
50
};
51
52
$container[DocumentMapping::class] = function () use ($container) {
53
    return new DocumentMapping($container[Resolver::class]);
54
};
55