resolveFromAttribute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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