CacheCollectorFactory::createService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license.
17
 *
18
 * CacheCollectorFactory.php
19
 * @data:       2017-02-08 21:22
20
 */
21
22
namespace DoctrineCacheToolbar\Factory\Collector;
23
24
use Interop\Container\ContainerInterface;
25
use Zend\ServiceManager\Factory\FactoryInterface;
26
use Zend\ServiceManager\ServiceLocatorInterface;
27
use DoctrineCacheToolbar\Collector\CacheCollector;
28
29
/**
30
 * Class CacheCollectorFactory
31
 * @package DoctrineCacheToolbar\Factory\Collector
32
 * @author: Szymon Michałowski <[email protected]>
33
 */
34
class CacheCollectorFactory implements FactoryInterface
35
{
36
    /**
37
     * @param ContainerInterface $container
38
     * @param null $name
39
     * @param array|null $options
40
     * @return mixed|CacheCollector
41
     */
42 1
    public function __invoke(ContainerInterface $container, $name = null, array $options = null)
43
    {
44 1
        $name = $name ? $name : CacheCollector::class;
45 1
        $class = new $name;
46 1
        $class->setEntityManager($container->get('Doctrine\ORM\EntityManager'));
47
48 1
        return $class;
49
    }
50
51
    /**
52
     * Create and return ControllerManager instance
53
     *
54
     * For use with zend-servicemanager v2; proxies to __invoke().
55
     *
56
     * @param ServiceLocatorInterface $serviceLocator
57
     * @return mixed|CacheCollector
58
     */
59 1
    public function createService(ServiceLocatorInterface $serviceLocator)
60
    {
61 1
        return $this($serviceLocator, CacheCollector::class);
62
    }
63
}