MultisiteResolverManager   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 6
Bugs 1 Features 5
Metric Value
wmc 7
c 6
b 1
f 5
lcom 1
cbo 2
dl 0
loc 53
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 13 5
A getHandler() 0 4 1
A init() 0 4 1
1
<?php
2
namespace Gwa\Wordpress;
3
4
use Exception;
5
use Gwa\Wordpress\WpBridge\Traits\WpBridgeTrait;
6
use Gwa\Wordpress\WpBridge\WpBridge;
7
8
class MultisiteResolverManager
9
{
10
    use WpBridgeTrait;
11
12
    const TYPE_SUBDOMAIN = '\Gwa\Wordpress\MultisiteSubDomainResolver';
13
    const TYPE_FOLDER = '\Gwa\Wordpress\MultisiteDirectoryResolver';
14
15
    /**
16
     * Resolver Handler.
17
     *
18
     * @var \Gwa\Wordpress\Contracts\MultisiteDirectoryResolver
19
     */
20
    protected $handler;
21
22
    /**
23
     * MultisiteResolverManager.
24
     *
25
     * @param string $wpdir
26
     * @param string $multisiteDomainType
27
     * @param null   $wpBridge
28
     */
29
    public function __construct($wpdir, $multisiteDomainType, $wpBridge = null)
30
    {
31
        if (!is_string($wpdir) || $wpdir === '' || $wpdir === '/') {
32
            throw new Exception('Please set the relative path to your Wordpress install folder.');
33
        }
34
35
        $this->setWpBridge(($wpBridge !== null) ? $wpBridge : new WpBridge());
36
37
        $handler = new $multisiteDomainType($wpdir);
38
        $handler->setWpBridge($this->getWpBridge());
39
40
        $this->handler = $handler;
41
    }
42
43
    /**
44
     * Get current Handler.
45
     *
46
     * @return \Gwa\Wordpress\Contracts\MultisiteDirectoryResolver
47
     */
48
    public function getHandler()
49
    {
50
        return $this->handler;
51
    }
52
53
    /**
54
     * Init all filter.
55
     */
56
    public function init()
57
    {
58
        $this->handler->init();
59
    }
60
}
61