Completed
Branch master (75e1cb)
by Gabriel
04:26 queued 01:51
created

ErrorHandler   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 7
dl 0
loc 21
c 0
b 0
f 0
ccs 0
cts 15
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 18 7
1
<?php
2
3
namespace Waredesk;
4
5
use Waredesk\Exceptions\AccountBannedException;
6
use Waredesk\Exceptions\AccountDeletedException;
7
use Waredesk\Exceptions\AccountInvalidException;
8
use Waredesk\Exceptions\EmailNotConfirmedException;
9
use Waredesk\Exceptions\InvalidClientException;
10
use Waredesk\Exceptions\InvalidRequestException;
11
use Waredesk\Exceptions\UnknownException;
12
13
class ErrorHandler
14
{
15
    public function __invoke(array $error)
16
    {
17
        switch ($error['error']) {
18
            case 'invalid_request':
19
                throw new InvalidRequestException($error['message']);
20
            case 'account_banned':
21
                throw new AccountBannedException($error['message']);
22
            case 'account_deleted':
23
                throw new AccountDeletedException($error['message']);
24
            case 'account_invalid':
25
                throw new AccountInvalidException($error['message']);
26
            case 'email_not_confirmed':
27
                throw new EmailNotConfirmedException($error['message']);
28
            case 'invalid_client':
29
                throw new InvalidClientException($error['message']);
30
        }
31
        throw new UnknownException();
32
    }
33
}
34