Type   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A summarize() 0 6 2
A getClassName() 0 6 2
1
<?php
2
namespace nochso\Omni;
3
4
/**
5
 * Type returns PHP type information.
6
 *
7
 * Uses:
8
 *
9
 * - writing nicer exception messages
10
 * - easier debugging
11
 */
12
final class Type {
13
	/**
14
	 * Summarize the type of any variable.
15
	 *
16
	 * @param mixed $value
17
	 *
18
	 * @return string Result of `get_class` for objects or `gettype` for anything else.
19
	 *
20
	 * @see gettype
21
	 * @see get_class
22
	 */
23
	public static function summarize($value) {
24
		if (!is_object($value)) {
25
			return gettype($value);
26
		}
27
		return get_class($value);
28
	}
29
30
	/**
31
	 * getClassName returns the class name without namespaces.
32
	 *
33
	 * @param object|string $object Object instance of a fully qualified name.
34
	 *
35
	 * @return string
36
	 */
37
	public static function getClassName($object) {
38
		if (is_object($object)) {
39
			$object = get_class($object);
40
		}
41
		return ltrim(substr($object, strrpos($object, '\\')), '\\');
42
	}
43
}
44