public static function CheckClassInterface ($testClassName, $interfaceName, $checkStaticMethods = FALSE, $throwException = TRUE) {
		$result = FALSE;
		$errorMsg = '';
		// check given test class for all implemented instance methods by given interface
		$interfaceName = trim($interfaceName, '\\');
		$testClassType = new \ReflectionClass($testClassName);
		if (in_array($interfaceName, $testClassType->getInterfaceNames(), TRUE)) {
			$result = TRUE;
		} else {
			$errorMsg = "Class `$testClassName` doesn't implement interface `$interfaceName`.";
		}
		if ($result && $checkStaticMethods) {
			// check given test class for all implemented static methods by given interface
			$allStaticsImplemented = TRUE;
			$interfaceMethods = static::checkClassInterfaceGetPublicStaticMethods($interfaceName);
			foreach ($interfaceMethods as $methodName) {
				if (!$testClassType->hasMethod($methodName)) {
					$allStaticsImplemented = FALSE;
					$errorMsg = "Class `$testClassName` doesn't implement static method `$methodName` from interface `$interfaceName`.";
					break;
				}
				$testClassStaticMethod = $testClassType->getMethod($methodName);
				if (!$testClassStaticMethod->isStatic()) {
					$allStaticsImplemented = FALSE;
					$errorMsg = "Class `$testClassName` doesn't implement static method `$methodName` from interface `$interfaceName`, method is not static.";
					break;
				}
				// arguments compatibility in presented static method are automatically checked by PHP
			}
			if (!$allStaticsImplemented) $result = FALSE;
		}
		// return result or thrown an exception
		if ($result) return TRUE;
		if (!$throwException) return FALSE;
		$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
		throw new \InvalidArgumentException("[".$selfClass."] " . $errorMsg);
	}
public static function CheckClassInterface ($testClassName, $interfaceName, $checkStaticMethods = FALSE, $throwException = TRUE) {
		$result = FALSE;
		$errorMsg = '';
		// check given test class for all implemented instance methods by given interface
		$interfaceName = trim($interfaceName, '\\');
		$testClassType = new \ReflectionClass($testClassName);
		if (in_array($interfaceName, $testClassType->getInterfaceNames(), TRUE)) {
			$result = TRUE;
		} else {
			$errorMsg = "Class `$testClassName` doesn't implement interface `$interfaceName`.";
		}
		if ($result && $checkStaticMethods) {
			// check given test class for all implemented static methods by given interface
			$allStaticsImplemented = TRUE;
			$interfaceMethods = static::checkClassInterfaceGetPublicStaticMethods($interfaceName);
			foreach ($interfaceMethods as $methodName) {
				if (!$testClassType->hasMethod($methodName)) {
					$allStaticsImplemented = FALSE;
					$errorMsg = "Class `$testClassName` doesn't implement static method `$methodName` from interface `$interfaceName`.";
					break;
				}
				$testClassStaticMethod = $testClassType->getMethod($methodName);
				if (!$testClassStaticMethod->isStatic()) {
					$allStaticsImplemented = FALSE;
					$errorMsg = "Class `$testClassName` doesn't implement static method `$methodName` from interface `$interfaceName`, method is not static.";
					break;
				}
				// arguments compatibility in presented static method are automatically checked by PHP
			}
			if (!$allStaticsImplemented) $result = FALSE;
		}
		// return result or thrown an exception
		if ($result) return TRUE;
		if (!$throwException) return FALSE;
		$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
		throw new \InvalidArgumentException("[".$selfClass."] " . $errorMsg);
	}
public static function CheckClassInterface ( $ testClassName , $ interfaceName , $ checkStaticMethods = FALSE , $ throwException = TRUE ) { $ result = FALSE ; $ errorMsg = '' ; // check given test class for all implemented instance methods by given interface $ interfaceName = trim ( $ interfaceName , '\\' ) ; $ testClassType = new \ ReflectionClass ( $ testClassName ) ; if ( in_array ( $ interfaceName , $ testClassType -> getInterfaceNames ( ) , TRUE ) ) { $ result = TRUE ; } else { $ errorMsg = "Class `$testClassName` doesn't implement interface `$interfaceName`." ; } if ( $ result && $ checkStaticMethods ) { // check given test class for all implemented static methods by given interface $ allStaticsImplemented = TRUE ; $ interfaceMethods = static :: checkClassInterfaceGetPublicStaticMethods ( $ interfaceName ) ; foreach ( $ interfaceMethods as $ methodName ) { if ( ! $ testClassType -> hasMethod ( $ methodName ) ) { $ allStaticsImplemented = FALSE ; $ errorMsg = "Class `$testClassName` doesn't implement static method `$methodName` from interface `$interfaceName`." ; break ; } $ testClassStaticMethod = $ testClassType -> getMethod ( $ methodName ) ; if ( ! $ testClassStaticMethod -> isStatic ( ) ) { $ allStaticsImplemented = FALSE ; $ errorMsg = "Class `$testClassName` doesn't implement static method `$methodName` from interface `$interfaceName`, method is not static." ; break ; } // arguments compatibility in presented static method are automatically checked by PHP } if ( ! $ allStaticsImplemented ) $ result = FALSE ; } // return result or thrown an exception if ( $ result ) return TRUE ; if ( ! $ throwException ) return FALSE ; $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; throw new \ InvalidArgumentException ( "[" . $ selfClass . "] " . $ errorMsg ) ; }
Check if given class implements given interface, else throw an exception.
@param string $testClassName Full test class name.
@param string $interfaceName Full interface class name.
@param bool $checkStaticMethods Check implementation of all static methods by interface static methods.
@param bool $throwException If `TRUE`, throw an exception if something is not implemented or if `FALSE` return `FALSE` only.
@throws \InvalidArgumentException
@return bool
Check if given class implements given interface else throw an exception .