Completed
Push — master ( 9e1d7e...773033 )
by
unknown
03:28
created

RepositoryException   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A wrongFormat() 0 4 1
A missingId() 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\Segment;
6
use Audiens\AppnexusClient\entity\SegmentBilling;
7
use Audiens\AppnexusClient\repository\RepositoryResponse;
8
9
/**
10
 * Class RepositoryException
11
 */
12
class RepositoryException extends \Exception
13
{
14
15
    /**
16
     * @param $responseContent
17
     *
18
     * @return self
19
     */
20
    public static function wrongFormat($responseContent)
21
    {
22
        return new self($responseContent);
23
    }
24
25
    /**
26
     * @param Segment $segment
27
     *
28
     * @return self
29
     */
30
    public static function missingId($segment)
31
    {
32
        return new self('Missing segment id for '.serialize($segment->getCode()));
33
    }
34
35
    /**
36
     * @param SegmentBilling $segment
37
     *
38
     * @return self
39
     */
40
    public static function missingSegmentBillingId($segment)
41
    {
42
        return new self('Missing segment billing id for '.serialize($segment->getId()));
43
    }
44
45
    /**
46
     * @param RepositoryResponse $repositoryResponse
47
     *
48
     * @return self
49
     */
50
    public static function failed(RepositoryResponse $repositoryResponse)
51
    {
52
        return new self('Failed call: '.$repositoryResponse->getError()->getError());
53
    }
54
55
    /**
56
     * @param string $reason
57
     *
58
     * @return self
59
     */
60
    public static function genericFailed($reason)
61
    {
62
        return new self($reason);
63
    }
64
65
    /**+
66
     * @param $missingIndex
67
     *
68
     * @return self
69
     */
70
    public static function missingIndex($missingIndex)
71
    {
72
        return new self('Invalid reposnse missing: '. $missingIndex);
73
    }
74
}
75