Completed
Branch master (a35590)
by Anton
04:28 queued 01:35
created

EnvelopeValidationException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 3
A getDetails() 0 4 1
1
<?php
2
3
namespace Covery\Client;
4
5
/**
6
 * Class EnvelopeValidationException
7
 *
8
 * Special exception class, thrown when envelope validation failed
9
 *
10
 * @package Covery\Client
11
 */
12
class EnvelopeValidationException extends Exception
13
{
14
    /**
15
     * @var string[]
16
     */
17
    private $details;
18
19
    /**
20
     * EnvelopeValidationException constructor.
21
     *
22
     * @param string[] $details
23
     */
24
    public function __construct(array $details)
25
    {
26
        if (count($details) === 0) {
27
            parent::__construct('Envelope validation failed');
28
            $details = [];
29
        } elseif (count($details) === 1) {
30
            parent::__construct($details[0]);
31
        } else {
32
            parent::__construct(
33
                sprintf(
34
                    'Envelope validation failed. %d asserts failed',
35
                    count($details)
36
                )
37
            );
38
        }
39
40
        $this->details = $details;
41
    }
42
43
    /**
44
     * @return string[]
45
     */
46
    public function getDetails()
47
    {
48
        return $this->details;
49
    }
50
}
51