Completed
Push — master ( 4ed653...39a76c )
by
unknown
02:20
created

RepositoryException::missingIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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
     * @return RepositoryException
27
     */
28
    public static function missingSegmentBillingContent()
29
    {
30
        return new self('Response returned an empty segment-billing-category');
31
    }
32
33
    /**
34
     * @param Segment $segment
35
     *
36
     * @return self
37
     */
38
    public static function missingId($segment)
39
    {
40
        return new self('Missing segment id for '.serialize($segment->getCode()));
41
    }
42
43
    /**
44
     * @param SegmentBilling $segment
45
     *
46
     * @return self
47
     */
48
    public static function missingSegmentBillingId($segment)
49
    {
50
        return new self('Missing segment billing id for '.serialize($segment->getId()));
51
    }
52
53
    /**
54
     * @param RepositoryResponse $repositoryResponse
55
     *
56
     * @return self
57
     */
58
    public static function failed(RepositoryResponse $repositoryResponse)
59
    {
60
        return new self('Failed call: '.$repositoryResponse->getError()->getError());
61
    }
62
63
    /**
64
     * @param string $reason
65
     *
66
     * @return self
67
     */
68
    public static function genericFailed($reason)
69
    {
70
        return new self($reason);
71
    }
72
73
    /**+
74
     * @param $missingIndex
75
     *
76
     * @return self
77
     */
78
    public static function missingIndex($missingIndex)
79
    {
80
        return new self('Invalid reposnse missing: '. $missingIndex);
81
    }
82
}
83