Code Duplication    Length = 33-48 lines in 2 locations

src/Tidal/WampWatch/Exception/NotAuthorizedException.php 1 location

@@ 19-66 (lines=48) @@
16
 *
17
 * Thrown when a router does not support a given meta topic
18
 */
19
class NotAuthorizedException extends \OutOfBoundsException
20
{
21
    const ERROR_RESPONSE = 'wamp.error.not_authorized';
22
23
    /**
24
     * @var string name of the topic
25
     */
26
    protected $topicName;
27
28
    /**
29
     * @param string $topicName
30
     * @param        string the router error message
31
     */
32
    public function __construct($topicName, $errorMsg = 'session is not authorized')
33
    {
34
        $this->setTopicName($topicName);
35
36
        parent::__construct($errorMsg);
37
    }
38
39
    /**
40
     * @param string $topicName
41
     */
42
    protected function setTopicName($topicName)
43
    {
44
        $this->topicName = $topicName;
45
    }
46
47
    /**
48
     * @return string the topic name
49
     */
50
    public function getTopicName()
51
    {
52
        return $this->topicName;
53
    }
54
55
    /**
56
     * Checks if a router response is a 'no_such_topic' error.
57
     *
58
     * @param $errorResponse
59
     *
60
     * @return bool
61
     */
62
    public static function isNotAuthrorizedError($errorResponse)
63
    {
64
        return $errorResponse == self::ERROR_RESPONSE;
65
    }
66
}
67

src/Tidal/WampWatch/Exception/UnknownTopicException.php 1 location

@@ 14-46 (lines=33) @@
11
12
namespace Tidal\WampWatch\Exception;
13
14
class UnknownTopicException extends \OutOfBoundsException
15
{
16
    /**
17
     * @var string name of the topic
18
     */
19
    protected $topicName;
20
21
    /**
22
     * @param string $topicName
23
     */
24
    public function __construct($topicName)
25
    {
26
        $this->setTopicName($topicName);
27
28
        parent::__construct("unknown topic '$topicName'");
29
    }
30
31
    /**
32
     * @param string $topicName
33
     */
34
    protected function setTopicName($topicName)
35
    {
36
        $this->topicName = $topicName;
37
    }
38
39
    /**
40
     * @return string the topic name
41
     */
42
    public function getTopicName()
43
    {
44
        return $this->topicName;
45
    }
46
}
47