Completed
Push — master ( f743de...f8a04a )
by Daniel
03:18
created

JsonRpcServerErrorException::validateCode()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Cmobi\RabbitmqBundle\Rpc\Exception;
4
5
6
abstract class JsonRpcServerErrorException extends JsonRpcGenericErrorException
7
{
8
    const ERROR_CODE = -32000;
9
10
    public function __construct($message = "Server error", \Exception $previous = null)
11
    {
12
        parent::__construct($message, self::validateCode(self::ERROR_CODE), $previous);
13
    }
14
15
    public function validateCode($code)
16
    {
17
        if ($code < -32000 || $code > -32099) {
18
            $this->message = "Server error";
19
            return self::ERROR_CODE;
20
        }
21
22
        return $code;
23
    }
24
}