RepositoryException   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 0
loc 43
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A wrongFormat() 0 4 1
A missingSegmentBillingContent() 0 4 1
A missingId() 0 4 1
A missingMemberDataSharingId() 0 4 1
A missingSegmentBillingId() 0 4 1
A failed() 0 4 1
A genericFailed() 0 4 1
A missingIndex() 0 4 1
1
<?php
2
3
namespace Audiens\AppnexusClient\exceptions;
4
5
use Audiens\AppnexusClient\entity\MemberDataSharing;
6
use Audiens\AppnexusClient\entity\Segment;
7
use Audiens\AppnexusClient\entity\SegmentBilling;
8
use Audiens\AppnexusClient\repository\RepositoryResponse;
9
10
class RepositoryException extends \Exception
11
{
12
13
    public static function wrongFormat(string $responseContent): self
14
    {
15
        return new self($responseContent);
16
    }
17
18
    public static function missingSegmentBillingContent(): self
19
    {
20
        return new self('Response returned an empty segment-billing-category');
21
    }
22
23
    public static function missingId(Segment $segment): self
24
    {
25
        return new self('Missing segment id for '.serialize($segment->getName()));
26
    }
27
28
    public static function missingMemberDataSharingId(MemberDataSharing $memberDataSharing): self
29
    {
30
        return new self('Missing Member data sharing id for '.serialize($memberDataSharing));
31
    }
32
33
    public static function missingSegmentBillingId(SegmentBilling $segmentsegmentBilling): self
34
    {
35
        return new self('Missing segment billing id for '.serialize($segmentsegmentBilling->getId()));
36
    }
37
38
    public static function failed(RepositoryResponse $repositoryResponse): self
39
    {
40
        return new self('Failed call: '.$repositoryResponse->getError()->getError());
41
    }
42
43
    public static function genericFailed(string $reason): self
44
    {
45
        return new self($reason);
46
    }
47
48
    public static function missingIndex(string $missingIndex): self
49
    {
50
        return new self('Invalid reposnse missing: '.$missingIndex);
51
    }
52
}
53