Completed
Pull Request — master (#8)
by Thomas Mauro
04:50
created

MarkdownFactory::__invoke()   A

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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 1
1
<?php
2
3
namespace MaglMarkdown\View\Helper;
4
5
use Interop\Container\ContainerInterface;
6
use Interop\Container\Exception\ContainerException;
7
use Zend\ServiceManager\AbstractPluginManager;
8
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
9
use Zend\ServiceManager\Exception\ServiceNotFoundException;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
13
/**
14
 * Class MarkdownFactory
15
 *
16
 * @package MaglMarkdown\View\Helper
17
 */
18
class MarkdownFactory implements FactoryInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Zend\ServiceManager\FactoryInterface has been deprecated with message: Use Zend\ServiceManager\Factory\FactoryInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
19
{
20
21
    /**
22
     * Create service
23
     *
24
     * @param ServiceLocatorInterface $serviceLocator
25
     * @return Markdown
26
     */
27
    public function createService(ServiceLocatorInterface $serviceLocator)
28
    {
29
        if ($serviceLocator instanceof AbstractPluginManager) {
30
            $serviceLocator = $serviceLocator->getServiceLocator() ?: $serviceLocator;
0 ignored issues
show
Deprecated Code introduced by
The method Zend\ServiceManager\Serv...er::getServiceLocator() has been deprecated with message: since 3.0.0. Factories using 3.0 should use the container instance passed to the factory instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
31
        }
32
33
        return $this($serviceLocator, Markdown::class);
34
    }
35
36
    /**
37
     * Create an object
38
     *
39
     * @param  ContainerInterface $container
40
     * @param  string             $requestedName
41
     * @param  null|array         $options
42
     * @return Markdown
43
     * @throws \Interop\Container\Exception\NotFoundException
44
     * @throws ServiceNotFoundException if unable to resolve the service.
45
     * @throws ServiceNotCreatedException if an exception is raised when
46
     *     creating a service.
47
     * @throws ContainerException if any other error occurs
48
     */
49 1
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
50
    {
51 1
        return new Markdown($container->get('MaglMarkdown\MarkdownService'));
52
    }
53
}
54