NoSuchProcedureException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 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
12
namespace Tidal\WampWatch\Exception;
13
14
/**
15
 * Class NoSuchProcedureException.
16
 *
17
 * Thrown when a router does not support a given meta procedure
18
 */
19
class NoSuchProcedureException extends \OutOfBoundsException
20
{
21
    const ERROR_RESPONSE = 'wamp.error.no_such_procedure';
22
23
    /**
24
     * @var string name of the procedure
25
     */
26
    protected $procedureName;
27
28
    /**
29
     * @param string $procedureName
30
     */
31
    public function __construct($procedureName)
32
    {
33
        $this->setprocedureName($procedureName);
34
35
        parent::__construct(sprintf(
36
            "Server seems to not support meta procedure '%s'. Response was: '%s'",
37
            $procedureName,
38
            self::ERROR_RESPONSE
39
        ));
40
    }
41
42
    /**
43
     * @param string $procedureName
44
     */
45
    protected function setProcedureName($procedureName)
46
    {
47
        $this->procedureName = $procedureName;
48
    }
49
50
    /**
51
     * @return string the procedure name
52
     */
53
    public function getProcedureName()
54
    {
55
        return $this->procedureName;
56
    }
57
58
    /**
59
     * Checks if a router response is a 'no_such_procedure' error.
60
     *
61
     * @param $errorResponse
62
     *
63
     * @return bool
64
     */
65
    public static function isNoProcedureError($errorResponse)
66
    {
67
        return $errorResponse == self::ERROR_RESPONSE;
68
    }
69
}
70