Code Duplication    Length = 47-48 lines in 6 locations

src/MaglMarkdown/Adapter/GithubMarkdownOptionsFactory.php 1 location

@@ 17-63 (lines=47) @@
14
 *
15
 * @package MaglMarkdown\Adapter
16
 */
17
class GithubMarkdownOptionsFactory implements FactoryInterface
18
{
19
20
    /**
21
     * Create service
22
     *
23
     * @param ServiceLocatorInterface $serviceLocator
24
     * @return Options\GithubMarkdownOptions
25
     */
26
    public function createService(ServiceLocatorInterface $serviceLocator)
27
    {
28
        return $this->create($serviceLocator);
29
    }
30
31
    /**
32
     * Create an object
33
     *
34
     * @param  ContainerInterface $container
35
     * @param  string             $requestedName
36
     * @param  null|array         $options
37
     * @return Options\GithubMarkdownOptions
38
     * @throws \Interop\Container\Exception\NotFoundException
39
     * @throws ServiceNotFoundException if unable to resolve the service.
40
     * @throws ServiceNotCreatedException if an exception is raised when
41
     *     creating a service.
42
     * @throws ContainerException if any other error occurs
43
     */
44
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
45
    {
46
        return $this->create($container);
47
    }
48
49
    /**
50
     * @param ServiceLocatorInterface|ContainerInterface $container
51
     * @return Options\GithubMarkdownOptions
52
     */
53
    protected function create($container)
54
    {
55
        if (!$container instanceof ServiceLocatorInterface && !$container instanceof ContainerInterface) {
56
            throw new \InvalidArgumentException('Invalid container to create service');
57
        }
58
59
        $config = $container->get('config');
60
61
        return new Options\GithubMarkdownOptions($config['magl_markdown']['adapter_config']['github_markdown']);
62
    }
63
}
64

src/MaglMarkdown/Adapter/MichelfPHPMarkdownAdapterFactory.php 1 location

@@ 17-63 (lines=47) @@
14
 *
15
 * @package MaglMarkdown\Adapter
16
 */
17
class MichelfPHPMarkdownAdapterFactory implements FactoryInterface
18
{
19
20
    /**
21
     * Create service
22
     *
23
     * @param ServiceLocatorInterface $serviceLocator
24
     * @return MichelfPHPMarkdownAdapter
25
     */
26
    public function createService(ServiceLocatorInterface $serviceLocator)
27
    {
28
        return $this->create($serviceLocator);
29
    }
30
31
    /**
32
     * Create an object
33
     *
34
     * @param  ContainerInterface $container
35
     * @param  string             $requestedName
36
     * @param  null|array         $options
37
     * @return MichelfPHPMarkdownAdapter
38
     * @throws \Interop\Container\Exception\NotFoundException
39
     * @throws ServiceNotFoundException if unable to resolve the service.
40
     * @throws ServiceNotCreatedException if an exception is raised when
41
     *     creating a service.
42
     * @throws ContainerException if any other error occurs
43
     */
44
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
45
    {
46
        return $this->create($container);
47
    }
48
49
    /**
50
     * @param ServiceLocatorInterface|ContainerInterface $container
51
     * @return MichelfPHPMarkdownAdapter
52
     */
53
    protected function create($container)
54
    {
55
        if (!$container instanceof ServiceLocatorInterface && !$container instanceof ContainerInterface) {
56
            throw new \InvalidArgumentException('Invalid container to create service');
57
        }
58
59
        $config = $container->get('config');
60
61
        return new MichelfPHPMarkdownAdapter($config['magl_markdown']['adapter_config']['michelf_markdown']);
62
    }
63
}
64

src/MaglMarkdown/Adapter/MichelfPHPMarkdownExtraAdapterFactory.php 1 location

@@ 17-63 (lines=47) @@
14
 *
15
 * @package MaglMarkdown\Adapter
16
 */
17
class MichelfPHPMarkdownExtraAdapterFactory implements FactoryInterface
18
{
19
20
    /**
21
     * Create service
22
     *
23
     * @param ServiceLocatorInterface $serviceLocator
24
     * @return mixed
25
     */
26
    public function createService(ServiceLocatorInterface $serviceLocator)
27
    {
28
        return $this->create($serviceLocator);
29
    }
30
31
    /**
32
     * Create an object
33
     *
34
     * @param  ContainerInterface $container
35
     * @param  string             $requestedName
36
     * @param  null|array         $options
37
     * @return MichelfPHPMarkdownExtraAdapter
38
     * @throws \Interop\Container\Exception\NotFoundException
39
     * @throws ServiceNotFoundException if unable to resolve the service.
40
     * @throws ServiceNotCreatedException if an exception is raised when
41
     *     creating a service.
42
     * @throws ContainerException if any other error occurs
43
     */
44
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
45
    {
46
        return $this->create($container);
47
    }
48
49
    /**
50
     * @param ServiceLocatorInterface|ContainerInterface $container
51
     * @return MichelfPHPMarkdownExtraAdapter
52
     */
53
    protected function create($container)
54
    {
55
        if (!$container instanceof ServiceLocatorInterface && !$container instanceof ContainerInterface) {
56
            throw new \InvalidArgumentException('Invalid container to create service');
57
        }
58
59
        $config = $container->get('config');
60
61
        return new MichelfPHPMarkdownExtraAdapter($config['magl_markdown']['adapter_config']['michelf_markdown_extra']);
62
    }
63
}
64

src/MaglMarkdown/Cache/CacheFactory.php 1 location

@@ 19-66 (lines=48) @@
16
 *
17
 * @package MaglMarkdown\Cache
18
 */
19
class CacheFactory implements FactoryInterface
20
{
21
22
    /**
23
     * Create service
24
     *
25
     * @param ServiceLocatorInterface $serviceLocator
26
     * @return StorageInterface
27
     */
28
    public function createService(ServiceLocatorInterface $serviceLocator)
29
    {
30
        return $this->create($serviceLocator);
31
    }
32
33
    /**
34
     * Create an object
35
     *
36
     * @param  ContainerInterface $container
37
     * @param  string             $requestedName
38
     * @param  null|array         $options
39
     * @return StorageInterface
40
     * @throws \Zend\Cache\Exception\InvalidArgumentException
41
     * @throws \Interop\Container\Exception\NotFoundException
42
     * @throws ServiceNotFoundException if unable to resolve the service.
43
     * @throws ServiceNotCreatedException if an exception is raised when
44
     *     creating a service.
45
     * @throws ContainerException if any other error occurs
46
     */
47
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
48
    {
49
        return $this->create($container);
50
    }
51
52
    /**
53
     * @param ServiceLocatorInterface|ContainerInterface $container
54
     * @return StorageInterface
55
     */
56
    protected function create($container)
57
    {
58
        if (!$container instanceof ServiceLocatorInterface && !$container instanceof ContainerInterface) {
59
            throw new \InvalidArgumentException('Invalid container to create service');
60
        }
61
62
        $config = $container->get('config');
63
64
        return StorageFactory::factory($config['magl_markdown']['cache']);
65
    }
66
}
67

src/MaglMarkdown/Adapter/ErusevParsedownAdapterFactory.php 1 location

@@ 17-64 (lines=48) @@
14
 *
15
 * @package MaglMarkdown\Adapter
16
 */
17
class ErusevParsedownAdapterFactory implements FactoryInterface
18
{
19
20
    /**
21
     * Create service
22
     *
23
     * @param ServiceLocatorInterface $serviceLocator
24
     * @return mixed
25
     */
26
    public function createService(ServiceLocatorInterface $serviceLocator)
27
    {
28
        return $this->create($serviceLocator);
29
    }
30
31
    /**
32
     * Create an object
33
     *
34
     * @param  ContainerInterface $container
35
     * @param  string             $requestedName
36
     * @param  null|array         $options
37
     * @return ErusevParsedownAdapter
38
     * @throws \Interop\Container\Exception\NotFoundException
39
     * @throws ServiceNotFoundException if unable to resolve the service.
40
     * @throws ServiceNotCreatedException if an exception is raised when
41
     *     creating a service.
42
     * @throws ContainerException if any other error occurs
43
     */
44
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
45
    {
46
        return $this->create($container);
47
    }
48
49
50
    /**
51
     * @param ServiceLocatorInterface|ContainerInterface $container
52
     * @return ErusevParsedownAdapter
53
     */
54
    protected function create($container)
55
    {
56
        if (!$container instanceof ServiceLocatorInterface && !$container instanceof ContainerInterface) {
57
            throw new \InvalidArgumentException('Invalid container to create service');
58
        }
59
60
        $config = $container->get('config');
61
62
        return new ErusevParsedownAdapter($config['magl_markdown']['adapter_config']['erusev_parsedown']);
63
    }
64
}
65

src/MaglMarkdown/Adapter/ErusevParsedownExtraAdapterFactory.php 1 location

@@ 17-64 (lines=48) @@
14
 *
15
 * @package MaglMarkdown\Adapter
16
 */
17
class ErusevParsedownExtraAdapterFactory implements FactoryInterface
18
{
19
20
    /**
21
     * Create service
22
     *
23
     * @param ServiceLocatorInterface $serviceLocator
24
     * @return mixed
25
     */
26
    public function createService(ServiceLocatorInterface $serviceLocator)
27
    {
28
        return $this->create($serviceLocator);
29
    }
30
31
    /**
32
     * Create an object
33
     *
34
     * @param  ContainerInterface $container
35
     * @param  string             $requestedName
36
     * @param  null|array         $options
37
     * @return ErusevParsedownExtraAdapter
38
     * @throws \Interop\Container\Exception\NotFoundException
39
     * @throws ServiceNotFoundException if unable to resolve the service.
40
     * @throws ServiceNotCreatedException if an exception is raised when
41
     *     creating a service.
42
     * @throws ContainerException if any other error occurs
43
     */
44
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
45
    {
46
        return $this->create($container);
47
    }
48
49
50
    /**
51
     * @param ServiceLocatorInterface|ContainerInterface $container
52
     * @return ErusevParsedownExtraAdapter
53
     */
54
    protected function create($container)
55
    {
56
        if (!$container instanceof ServiceLocatorInterface && !$container instanceof ContainerInterface) {
57
            throw new \InvalidArgumentException('Invalid container to create service');
58
        }
59
60
        $config = $container->get('config');
61
62
        return new ErusevParsedownExtraAdapter($config['magl_markdown']['adapter_config']['erusev_parsedown_extra']);
63
    }
64
}
65