Completed
Push — master ( ea20ea...a25393 )
by Timo
41s
created

NoSuchProcedureException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A setProcedureName() 0 4 1
A getProcedureName() 0 4 1
A isNoProcedureError() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Tidal/WampWatch package.
5
 *   (c) 2016 Timo Michna <timomichna/yahoo.de>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 */
10
11
namespace Tidal\WampWatch\Exception;
12
13
/**
14
 * Class NoSuchProcedureException.
15
 *
16
 * Thrown when a router does not support a given meta procedure
17
 */
18
class NoSuchProcedureException extends \OutOfBoundsException
19
{
20
    const ERROR_RESPONSE = 'wamp.error.no_such_procedure';
21
22
    /**
23
     * @var string name of the procedure
24
     */
25
    protected $procedureName;
26
27
    /**
28
     * @param string $procedureName
29
     */
30
    public function __construct($procedureName)
31
    {
32
        $this->setprocedureName($procedureName);
33
34
        parent::__construct(sprintf(
35
            "Server seems to not support meta procedure '%s'. Response was: '%s'",
36
            $procedureName,
37
            self::ERROR_RESPONSE
38
        ));
39
    }
40
41
    /**
42
     * @param string $procedureName
43
     */
44
    protected function setProcedureName($procedureName)
45
    {
46
        $this->procedureName = $procedureName;
47
    }
48
49
    /**
50
     * @return string the procedure name
51
     */
52
    public function getProcedureName()
53
    {
54
        return $this->procedureName;
55
    }
56
57
    /**
58
     * Checks if a router response is a 'no_such_procedure' error.
59
     *
60
     * @param $errorResponse
61
     *
62
     * @return bool
63
     */
64
    public static function isNoProcedureError($errorResponse)
65
    {
66
        return $errorResponse == self::ERROR_RESPONSE;
67
    }
68
}
69