Completed
Branch Gutenberg/master (3b2a95)
by
unknown
118:45 queued 105:17
created

RouteMatchSpecificationFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createNewRouteMatchSpecification() 0 5 1
A create() 0 8 1
1
<?php
2
3
namespace EventEspresso\core\services\route_match;
4
5
use EventEspresso\core\domain\entities\route_match\RouteMatchSpecification;
6
use EventEspresso\core\exceptions\InvalidDataTypeException;
7
use EventEspresso\core\exceptions\InvalidInterfaceException;
8
use EventEspresso\core\services\factory\FactoryWithDependencyResolver;
9
use EventEspresso\core\services\loaders\LoaderFactory;
10
use EventEspresso\core\services\loaders\LoaderInterface;
11
use InvalidArgumentException;
12
use ReflectionException;
13
14
/**
15
 * Class RouteMatchSpecificationFactory
16
 * Factory for generating RouteMatchSpecification classes.
17
 * Will automatically resolve dependencies using the
18
 * RouteMatchSpecificationDependencyResolver
19
 *
20
 * @package EventEspresso\core\services\route_match
21
 * @author  Brent Christensen
22
 * @since   $VID:$
23
 */
24
class RouteMatchSpecificationFactory extends FactoryWithDependencyResolver
25
{
26
27
    /**
28
     * RouteMatchSpecificationFactory constructor
29
     *
30
     * @param RouteMatchSpecificationDependencyResolver $dependency_resolver
31
     * @param LoaderInterface                           $loader
32
     */
33
    public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader)
34
    {
35
        parent::__construct($dependency_resolver, $loader);
36
    }
37
38
    /**
39
     * @param $fqcn
40
     * @return RouteMatchSpecification
41
     * @throws InvalidDataTypeException
42
     * @throws ReflectionException
43
     * @since $VID:$
44
     */
45
    public function createNewRouteMatchSpecification($fqcn)
46
    {
47
        $this->dependencyResolver()->resolveDependenciesForClass($fqcn);
48
        return $this->loader()->getShared($fqcn);
49
    }
50
51
52
    /**
53
     * @param $fqcn
54
     * @return RouteMatchSpecification
55
     * @throws InvalidArgumentException
56
     * @throws InvalidDataTypeException
57
     * @throws InvalidInterfaceException
58
     * @throws ReflectionException
59
     * @since $VID:$
60
     */
61
    public static function create($fqcn)
62
    {
63
        /** @var RouteMatchSpecificationFactory $specification_factory */
64
        $specification_factory = LoaderFactory::getLoader()->getShared(
65
            'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory'
66
        );
67
        return $specification_factory->createNewRouteMatchSpecification($fqcn);
68
    }
69
}
70