Completed
Push — master ( ca3689...4c26e4 )
by Francesco
04:20
created

RepositoryException::failed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
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\repository\RepositoryResponse;
7
8
/**
9
 * Class RepositoryException
10
 */
11
class RepositoryException extends \Exception
12
{
13
14
    /**
15
     * @param $responseContent
16
     *
17
     * @return RepositoryException
18
     */
19
    public static function wrongFormat($responseContent)
20
    {
21
        return new self($responseContent);
22
    }
23
24
    /**
25
     * @param Segment $segment
26
     *
27
     * @return RepositoryException
28
     */
29
    public static function missingId(Segment $segment)
30
    {
31
        return new self('Missing segment id for '.serialize($segment->getCode()));
32
    }
33
34
    /**
35
     * @param RepositoryResponse $repositoryResponse
36
     *
37
     * @return RepositoryException
38
     */
39
    public static function failed(RepositoryResponse $repositoryResponse)
40
    {
41
        return new self('Failed call: '.$repositoryResponse->getError()->getError());
42
    }
43
44
    /**+
45
     * @param $missingIndex
46
     *
47
     * @return RepositoryException
48
     */
49
    public static function missingIndex($missingIndex)
50
    {
51
        return new self('Invalid reposnse missing: '. $missingIndex);
52
    }
53
}
54