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

JsonRpcServerErrorException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validateCode() 0 9 3
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
}