Carbon_Breadcrumb_Factory::verify_class_name()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 3
nc 4
nop 2
1
<?php
2
/**
3
 * A base for factories.
4
 *
5
 * @package carbon-breadcrumbs
6
 */
7
8
/**
9
 * Factory base class.
10
 *
11
 * Used as a base for breadcrumb classes that include factories.
12
 */
13
class Carbon_Breadcrumb_Factory {
14
15
	/**
16
	 * Verify the class name to use in factory.
17
	 * Make sure that the class exists.
18
	 *
19
	 * @static
20
	 * @access public
21
	 *
22
	 * @param string $class The class name.
23
	 * @param string $message The message to display in the exception if the class does not exist.
24
	 * @return string $class The class name.
25
	 *
26
	 * @throws Carbon_Breadcrumb_Exception If the built class name does not exist.
27
	 */
28
	public static function verify_class_name( $class, $message = '' ) {
29
		if ( ! $message ) {
30
			$message = 'Unexisting class: ' . $class;
31
		}
32
33
		if ( ! class_exists( $class ) ) {
34
			throw new Carbon_Breadcrumb_Exception( $message );
35
		}
36
37
		return $class;
38
	}
39
40
}
41