Set_Up_Automator::validate_namespace( $class_name,  $file_name,  $file )


Parameters Parameters

$class_name

(Required)

$file_name

(Required)

$file

(Required)


Top ↑

Return Return

(mixed|string)


Source Source

File: src/core/classes/class-set-up-automator.php

	/**
	 * @param $class_name
	 * @param $file_name
	 * @param $file
	 *
	 * @return mixed|string
	 */
	public function validate_namespace( $class_name, $file_name, $file ) {
		$class_name = strtoupper( $class_name );
		try {
			$is_free = new \ReflectionClass( 'Uncanny_Automator\\' . $class_name );
			if ( $is_free->inNamespace() ) {
				return 'Uncanny_Automator\\' . $class_name;
			}
		} catch ( ReflectionException $e ) { //phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
		}

		try {
			$is_pro = new \ReflectionClass( 'Uncanny_Automator_Pro\\' . $class_name );
			if ( $is_pro->inNamespace() ) {
				return 'Uncanny_Automator_Pro\\' . $class_name;
			}
		} catch ( ReflectionException $e ) { //phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
		}

		try {
			$custom_namespace = apply_filters( 'automator_class_namespace', __NAMESPACE__, $class_name, $file_name, $file );
			$is_custom        = new \ReflectionClass( $custom_namespace . '\\' . $class_name );