AMQPlainMechanism::getResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
ccs 13
cts 13
cp 1
rs 9.4285
cc 1
eloc 12
nc 1
nop 2
crap 1
1
<?php
2
3
namespace ButterAMQP\Security\Mechanism;
4
5
use ButterAMQP\Security\MechanismInterface;
6
7
class AMQPlainMechanism implements MechanismInterface
8
{
9
    const LOGIN_KEY = 'LOGIN';
10
    const PASSWORD_KEY = 'PASSWORD';
11
    const STRING_TYPE_HINT = 'S';
12
13
    /**
14
     * {@inheritdoc}
15
     */
16 19
    public function getName()
17
    {
18 19
        return 'AMQPLAIN';
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 19
    public function getResponse($username, $password)
25
    {
26 19
        return implode('', [
27 19
            pack('C', strlen(self::LOGIN_KEY)),
28 19
            self::LOGIN_KEY,
29 19
            self::STRING_TYPE_HINT,
30 19
            pack('N', strlen($username)),
31 19
            $username,
32 19
            pack('C', strlen(self::PASSWORD_KEY)),
33 19
            self::PASSWORD_KEY,
34 19
            self::STRING_TYPE_HINT,
35 19
            pack('N', strlen($password)),
36 19
            $password,
37 19
        ]);
38
    }
39
}
40