StringToObjectConverter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 6 1
1
<?php
2
3
namespace Ddeboer\DataImport\ValueConverter;
4
5
use Doctrine\Common\Persistence\ObjectRepository;
6
7
/**
8
 * Converts a string to an object
9
 *
10
 * @author Markus Bachmann <[email protected]>
11
 */
12
class StringToObjectConverter
13
{
14
    /**
15
     * @var ObjectRepository
16
     */
17
    private $repository;
18
19
    /**
20
     * @var string
21
     */
22
    private $property;
23
24
    /**
25
     * @param ObjectRepository $repository
26
     * @param string           $property
27
     */
28 1
    public function __construct(ObjectRepository $repository, $property)
29
    {
30 1
        $this->repository = $repository;
31 1
        $this->property = $property;
32 1
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function __invoke($input)
38
    {
39 1
        $method = 'findOneBy'.ucfirst($this->property);
40
41 1
        return $this->repository->$method($input);
42
    }
43
}
44