Completed
Pull Request — master (#39)
by
unknown
01:55
created

Carbon_Breadcrumb_Factory::verify_class_name()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.3332

Importance

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