class-integration-fixture.php
1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* Class MC4WP_Integration_Fixture
*
* @since 3.0
* @ignore
*/
class MC4WP_Integration_Fixture
{
/**
* @var string
*/
public $slug;
/**
* @var string
*/
public $class;
/**
* @var bool
*/
public $enabled;
/**
* @var bool
*/
public $enabled_by_default;
/**
* @var MC4WP_Integration
*/
public $instance;
/**
* @var array
*/
public $options;
/**
* @param string $slug
* @param string $class
* @param bool $enabled_by_default
* @param array $options
*/
public function __construct($slug, $class, $enabled_by_default, array $options)
{
$this->slug = $slug;
$this->class = $class;
$this->enabled_by_default = $enabled_by_default;
$this->enabled = $enabled_by_default;
$this->options = $options;
if (! empty($options['enabled'])) {
$this->enabled = true;
}
}
/**
* Returns the actual instance
*
* @return MC4WP_Integration
*/
public function load()
{
if (! $this->instance instanceof MC4WP_Integration) {
$this->instance = new $this->class($this->slug, $this->options);
}
return $this->instance;
}
/**
* Tunnel everything to MC4WP_Integration class
*
* @param string $name
* @param array $arguments
*
* @return MC4WP_Integration
*/
public function __call($name, $arguments)
{
return call_user_func_array(array( $this->load(), $name ), $arguments);
}
/**
* @param string $name
*
* @return string
*/
public function __get($name)
{
return $this->load()->$name;
}
/**
* @return string
*/
public function __toString()
{
return $this->slug;
}
}