How to check if device orientation is landscape left or right in swift?

This works on Swift 3 & 4

switch UIApplication.shared.statusBarOrientation {
    case .portrait:
        //do something
        break
    case .portraitUpsideDown:
        //do something
        break
    case .landscapeLeft:
    //do something
        break
    case .landscapeRight:
        //do something
        break
    case .unknown:
        //default
        break
 }

you can do something like,

if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft{

}
else if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeRight{

}
else if UIDevice.currentDevice().orientation == UIDeviceOrientation.UIDeviceOrientationPortraitUpsideDown{

}
else if UIDevice.currentDevice().orientation == UIDeviceOrientation.UIDeviceOrientationPortrait{

}

SWIFT 5

    if UIDevice.current.orientation.isLandscape {

    } else if UIDevice.current.orientation.isFlat {

    } else if UIDevice.current.orientation.isPortrait {

    } else if UIDevice.current.orientation.isValidInterfaceOrientation {

    }

SWIFT 3

if UIDevice.current.orientation == UIDeviceOrientation.landscapeLeft {

} else if UIDevice.current.orientation == UIDeviceOrientation.landscapeRight {

} else if UIDevice.current.orientation == UIDeviceOrientation.portrait {

} else if UIDevice.current.orientation == UIDeviceOrientation.portraitUpsideDown {

        }