DocumentDataSourceFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB;
12
13
use Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB\Query\ComparatorVisitorFactoryInterface;
14
use Cubiche\Infrastructure\Repository\Doctrine\ODM\MongoDB\Query\SpecificationVisitorFactoryInterface;
15
use Doctrine\ODM\MongoDB\DocumentManager;
16
17
/**
18
 * Document Data Source Factory Class.
19
 *
20
 * @author Karel Osorio Ramírez <[email protected]>
21
 */
22
class DocumentDataSourceFactory implements DocumentDataSourceFactoryInterface
23
{
24
    /**
25
     * @var DocumentManager
26
     */
27
    protected $dm;
28
29
    /**
30
     * @var SpecificationVisitorFactoryInterface
31
     */
32
    protected $specificationVisitorFactory;
33
34
    /**
35
     * @var ComparatorVisitorFactoryInterface
36
     */
37
    protected $comparatorVisitorFactory;
38
39
    /**
40
     * @param DocumentManager                      $dm
41
     * @param SpecificationVisitorFactoryInterface $specificationVisitorFactory
42
     * @param ComparatorVisitorFactoryInterface    $comparatorVisitorFactory
43
     */
44
    public function __construct(
45
        DocumentManager $dm,
46
        SpecificationVisitorFactoryInterface $specificationVisitorFactory,
47
        ComparatorVisitorFactoryInterface $comparatorVisitorFactory
48
    ) {
49
        $this->dm = $dm;
50
        $this->specificationVisitorFactory = $specificationVisitorFactory;
51
        $this->comparatorVisitorFactory = $comparatorVisitorFactory;
52
    }
53
54
    public function create($documentName = null)
55
    {
56
        return new DocumentDataSource(
57
            $this->dm,
58
            $this->specificationVisitorFactory,
59
            $this->comparatorVisitorFactory,
60
            $documentName
61
        );
62
    }
63
}
64