SubmissionException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getFieldErrors() 0 9 2
A jsonSerialize() 0 4 1
1
<?php
2
3
namespace allejo\Wufoo\Exceptions;
4
5
use Throwable;
6
7
class SubmissionException extends \RuntimeException implements \JsonSerializable
8
{
9
    private $jsonResponse;
10
11
    public function __construct(array $jsonResponse, $message = "", $code = 0, Throwable $previous = null)
12
    {
13
        parent::__construct($message, $code, $previous);
14
15
        $this->jsonResponse = $jsonResponse;
16
17
        if (isset($jsonResponse['ErrorText']))
18
        {
19
            $this->message = $jsonResponse['ErrorText'];
20
        }
21
    }
22
23
    public function getFieldErrors()
24
    {
25
        if (isset($this->jsonResponse['FieldErrors']))
26
        {
27
            return $this->jsonResponse['FieldErrors'];
28
        }
29
30
        return [];
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function jsonSerialize()
37
    {
38
        return $this->jsonResponse;
39
    }
40
}
41