| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | namespace Worldline\Acquiring\Sdk\V1; |
| 6: | |
| 7: | use Worldline\Acquiring\Sdk\CallContext; |
| 8: | use Worldline\Acquiring\Sdk\Domain\DataObject; |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | class ExceptionFactory |
| 16: | { |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | public function createException( |
| 24: | $httpStatusCode, |
| 25: | DataObject $errorObject, |
| 26: | CallContext $callContext = null |
| 27: | ) { |
| 28: | if ($httpStatusCode === 400) { |
| 29: | return new ValidationException($httpStatusCode, $errorObject); |
| 30: | } |
| 31: | if ($httpStatusCode === 403) { |
| 32: | return new AuthorizationException($httpStatusCode, $errorObject); |
| 33: | } |
| 34: | if ($httpStatusCode === 404) { |
| 35: | return new ReferenceException($httpStatusCode, $errorObject); |
| 36: | } |
| 37: | if ($httpStatusCode === 409) { |
| 38: | return new ReferenceException($httpStatusCode, $errorObject); |
| 39: | } |
| 40: | if ($httpStatusCode === 410) { |
| 41: | return new ReferenceException($httpStatusCode, $errorObject); |
| 42: | } |
| 43: | if ($httpStatusCode === 500) { |
| 44: | return new PlatformException($httpStatusCode, $errorObject); |
| 45: | } |
| 46: | if ($httpStatusCode === 502) { |
| 47: | return new PlatformException($httpStatusCode, $errorObject); |
| 48: | } |
| 49: | if ($httpStatusCode === 503) { |
| 50: | return new PlatformException($httpStatusCode, $errorObject); |
| 51: | } |
| 52: | return new ApiException($httpStatusCode, $errorObject); |
| 53: | } |
| 54: | } |
| 55: | |