DoctrinePathAttributeResolver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 18
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A resolveFromAttribute() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\Bundle\ApiBundle\Service\PathAttributeResolver;
5
6
use Doctrine\Common\Persistence\ObjectRepository;
7
8
class DoctrinePathAttributeResolver implements PathAttributeResolverInterface
9
{
10
    private $repository;
11
    private $searchField;
12
13 96
    public function __construct(ObjectRepository $repository, string $searchField)
14
    {
15 96
        $this->repository = $repository;
16 96
        $this->searchField = $searchField;
17 96
    }
18
19 1
    public function resolveFromAttribute($attributeValue)
20
    {
21 1
        return $this->repository->findOneBy(
22 1
            [$this->searchField => $attributeValue]
23
        );
24
    }
25
}
26