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

RepositoryException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A wrongFormat() 0 4 1
A missingId() 0 4 1
A failed() 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\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