Completed
Push — master ( b5c840...3d5461 )
by Marcus
04:46
created

SimpleFinderFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 23
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createFinder() 0 11 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Repositories\Finders\SimpleFinderFactory
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2019 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Repositories\Finders;
22
23
use TechDivision\Import\Repositories\FinderAwareRepositoryInterface;
24
25
/**
26
 * Factory implementations for simple finder instances.
27
 *
28
 * @author    Tim Wagner <[email protected]>
29
 * @copyright 2019 TechDivision GmbH <[email protected]>
30
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
31
 * @link      https://github.com/techdivision/import
32
 * @link      http://www.techdivision.com
33
 */
34
class SimpleFinderFactory implements FinderFactoryInterface
35
{
36
37
    /**
38
     * Initialize's and return's a new finder instance.
39
     *
40
     * @param \TechDivision\Import\Repositories\FinderAwareRepositoryInterface $repository The repository instance to create the finder for
41
     * @param string                                                           $key        The key of the prepared statement
42
     *
43
     * @return \TechDivision\Import\Repositories\Finders\FinderInterface The finder instance
44
     */
45
    public function createFinder(FinderAwareRepositoryInterface $repository, $key)
46
    {
47
        return new SimpleFinder(
48
            $repository->getConnection()->prepare(
49
                $repository->loadStatement($key)
50
            ),
51
            $key,
52
            $repository->getPrimaryKeyName(),
53
            $repository->getEntityName()
54
        );
55
    }
56
}
57