public static function hasTrait($class, $traitName, $isRecursive = false)
    {
        if (is_string($class)) {
            $class = new \ReflectionClass($class);
        }

        if (in_array($traitName, $class->getTraitNames(), true)) {
            return true;
        }

        $parentClass = $class->getParentClass();

        if ((false === $isRecursive) || (false === $parentClass) || (null === $parentClass)) {
            return false;
        }

        return static::hasTrait($parentClass, $traitName, $isRecursive);
    }