Passed
Push — master ( 289cbe...3ce129 )
by Anton
03:29
created

Extension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 4 2
A validate() 0 4 2
A __callStatic() 0 6 2
1
<?php
2
3
/**
4
 * @package Cadmium\System\Modules\Extend
5
 * @author Anton Romanov
6
 * @copyright Copyright (c) 2015-2017, Anton Romanov
7
 * @link http://cadmium-cms.com
8
 */
9
10
namespace Modules\Extend\Utils {
11
12
	abstract class Extension {
13
14
		protected static $loader = null;
15
16
		/**
17
		 * Check if an item name is valid
18
		 */
19
20
		public static function isValid(string $name) : bool {
21
22
			return (preg_match(static::$regex_name, $name) ? true : false);
23
		}
24
25
		/**
26
 		 * Validate an item name
27
 		 *
28
 		 * @return string|false : the name or false on failure
29
 		 */
30
31
		public static function validate(string $name) {
32
33
			return (preg_match(static::$regex_name, $name) ? $name : false);
34
		}
35
36
		/**
37
		 * Static overloader
38
		 */
39
40
		public static function __callStatic($name, $arguments) {
41
42
			if (null !== static::$loader) return static::$loader->$name(...$arguments);
43
44
			throw new \BadMethodCallException('Call to undefined method ' . get_called_class() . '::' . $name . '()');
45
		}
46
	}
47
}
48