Completed
Push — master ( 339dcc...fa58da )
by Daniel
13:39
created

RpcServerErrorException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Cmobi\RabbitmqBundle\Rpc\Exception;
4
5
6
abstract class RpcServerErrorException extends RpcGenericErrorException
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
}