for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Waredesk;
use Waredesk\Exceptions\AccountBannedException;
use Waredesk\Exceptions\AccountDeletedException;
use Waredesk\Exceptions\AccountInvalidException;
use Waredesk\Exceptions\EmailNotConfirmedException;
use Waredesk\Exceptions\InvalidClientException;
use Waredesk\Exceptions\InvalidRequestException;
use Waredesk\Exceptions\UnknownException;
class ErrorHandler
{
public static function error(array $error)
switch($error['error']) {
case 'invalid_request': throw new InvalidRequestException($error['message']);
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
switch ($expr) { case "A": doSomething(); //right break; case "B": doSomethingElse(); //wrong break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.
As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.
break
switch ($expr) { case "A": doSomething(); break; //wrong case "B": doSomething(); break; //right case "C:": doSomething(); return true; //right }
case 'account_banned': throw new AccountBannedException($error['message']);
case 'account_deleted': throw new AccountDeletedException($error['message']);
case 'account_invalid': throw new AccountInvalidException($error['message']);
case 'email_not_confirmed': throw new EmailNotConfirmedException($error['message']);
case 'invalid_client': throw new InvalidClientException($error['message']);
throw new UnknownException();
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.