Passed
Push — feature/initial-implementation ( 70fbec...2d1ee1 )
by Fike
02:35
created

EntityProviderWrapperMappingProvider::exists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AmaTeam\ElasticSearch\Entity\Mapping;
6
7
use AmaTeam\ElasticSearch\API\Entity\Mapping\ClassMappingInterface;
8
use AmaTeam\ElasticSearch\API\Entity\Mapping\ProviderInterface;
9
use AmaTeam\ElasticSearch\API\Entity\ProviderInterface as EntityProviderInterface;
10
11
class EntityProviderWrapperMappingProvider implements ProviderInterface
12
{
13
    /**
14
     * @var EntityProviderInterface
15
     */
16
    private $provider;
17
18
    /**
19
     * @param EntityProviderInterface $provider
20
     */
21
    public function __construct(EntityProviderInterface $provider)
22
    {
23
        $this->provider = $provider;
24
    }
25
26
    public function exists(string $name): bool
27
    {
28
        return $this->provider->exists($name);
29
    }
30
31
    public function get(string $name): ClassMappingInterface
32
    {
33
        return $this->provider->getResolved($name)->getMapping();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->provider->...ed($name)->getMapping() could return the type null which is incompatible with the type-hinted return AmaTeam\ElasticSearch\AP...g\ClassMappingInterface. Consider adding an additional type-check to rule them out.
Loading history...
34
    }
35
36
    public function find(string $name): ?ClassMappingInterface
37
    {
38
        $entity = $this->provider->findResolved($name);
39
        return $entity ? $entity->getMapping() : null;
40
    }
41
}
42