-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathHelper.php
49 lines (40 loc) · 1.13 KB
/
Helper.php
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
<?php
namespace AC;
use AC;
use InvalidArgumentException;
/**
* Class AC\Helper
* Implements __call to work around any keyword restrictions for PHP versions > 7
* @property Helper\Arrays array
* @property Helper\Date date
* @property Helper\Image image
* @property Helper\Post post
* @property Helper\Menu menu
* @property Helper\Strings string
* @property Helper\Taxonomy taxonomy
* @property Helper\User user
* @property Helper\Icon icon
* @property Helper\Html html
* @property Helper\Media media
* @property Helper\Network network
* @property Helper\File file
*/
final class Helper
{
public function __get(string $helper)
{
switch ($helper) {
// Hotfix
case 'string' :
return new AC\Helper\Strings();
case 'array' :
return new AC\Helper\Arrays();
default :
$class = 'AC\Helper\\' . ucfirst($helper);
if (class_exists($class)) {
return new $class();
}
}
throw new InvalidArgumentException('Invalid helper.');
}
}