SubmissionException::getFieldErrors()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
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