public static function CheckClassTrait ($testClassName, $traitName, $checkParentClasses = FALSE, $throwException = TRUE) {
		$result = FALSE;
		$errorMsg = '';
		// check given test class for all implemented instance methods by given interface
		$testClassType = new \ReflectionClass($testClassName);
		if (in_array($traitName, $testClassType->getTraitNames(), TRUE)) {
			$result = TRUE;
		} else if ($checkParentClasses) {
			$currentClassType = $testClassType;
			while (TRUE) {
				$parentClass = $currentClassType->getParentClass();
				if ($parentClass === FALSE) break;
				$parentClassType = new \ReflectionClass($parentClass->getName());
				if (in_array($traitName, $parentClassType->getTraitNames(), TRUE)) {
					$result = TRUE;
					break;
				} else {
					$currentClassType = $parentClassType;
				}
			}
		}
		if (!$result) 
			$errorMsg = "Class `$testClassName` doesn't implement trait `$traitName`.";
		// 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 CheckClassTrait ($testClassName, $traitName, $checkParentClasses = FALSE, $throwException = TRUE) {
		$result = FALSE;
		$errorMsg = '';
		// check given test class for all implemented instance methods by given interface
		$testClassType = new \ReflectionClass($testClassName);
		if (in_array($traitName, $testClassType->getTraitNames(), TRUE)) {
			$result = TRUE;
		} else if ($checkParentClasses) {
			$currentClassType = $testClassType;
			while (TRUE) {
				$parentClass = $currentClassType->getParentClass();
				if ($parentClass === FALSE) break;
				$parentClassType = new \ReflectionClass($parentClass->getName());
				if (in_array($traitName, $parentClassType->getTraitNames(), TRUE)) {
					$result = TRUE;
					break;
				} else {
					$currentClassType = $parentClassType;
				}
			}
		}
		if (!$result) 
			$errorMsg = "Class `$testClassName` doesn't implement trait `$traitName`.";
		// 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 CheckClassTrait ( $ testClassName , $ traitName , $ checkParentClasses = FALSE , $ throwException = TRUE ) { $ result = FALSE ; $ errorMsg = '' ; // check given test class for all implemented instance methods by given interface $ testClassType = new \ ReflectionClass ( $ testClassName ) ; if ( in_array ( $ traitName , $ testClassType -> getTraitNames ( ) , TRUE ) ) { $ result = TRUE ; } else if ( $ checkParentClasses ) { $ currentClassType = $ testClassType ; while ( TRUE ) { $ parentClass = $ currentClassType -> getParentClass ( ) ; if ( $ parentClass === FALSE ) break ; $ parentClassType = new \ ReflectionClass ( $ parentClass -> getName ( ) ) ; if ( in_array ( $ traitName , $ parentClassType -> getTraitNames ( ) , TRUE ) ) { $ result = TRUE ; break ; } else { $ currentClassType = $ parentClassType ; } } } if ( ! $ result ) $ errorMsg = "Class `$testClassName` doesn't implement trait `$traitName`." ; // 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 trait, else throw an exception.
@param string $testClassName Full test class name.
@param string $traitName Full trait class name.
@param bool $checkParentClasses If `TRUE`, trait implementation will be checked on all parent classes until success. Default is `FALSE`.
@param bool $throwException If `TRUE`, throw an exception if trait is not implemented or if `FALSE` return `FALSE` only.
@throws \InvalidArgumentException
@return boolean
Check if given class implements given trait else throw an exception .