AuthResponse::getBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 2 Features 1
Metric Value
c 2
b 2
f 1
dl 0
loc 8
rs 9.4286
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
namespace Cassandra\Request;
3
use Cassandra\Protocol\Frame;
4
5
class AuthResponse extends Request{
6
	
7
	protected $opcode = Frame::OPCODE_AUTH_RESPONSE;
8
	
9
	/**
10
	 * 
11
	 * @var string
12
	 */
13
	protected $_username;
14
	
15
	/**
16
	 *
17
	 * @var string
18
	 */
19
	protected $_password;
20
	
21
	/**
22
	 * CREDENTIALS
23
	 *
24
	 * Provides credentials information for the purpose of identification. This
25
	 * message comes as a response to an AUTHENTICATE message from the server, but
26
	 * can be use later in the communication to change the authentication
27
	 * information.
28
	 *
29
	 * The body is a list of key/value informations. It is a [short] n, followed by n
30
	 * pair of [string]. These key/value pairs are passed as is to the Cassandra
31
	 * IAuthenticator and thus the detail of which informations is needed depends on
32
	 * that authenticator.
33
	 *
34
	 * The response to a CREDENTIALS is a READY message (or an ERROR message).
35
	 *
36
	 * @param string $username
37
	 * @param string $password
38
	 */
39
	public function __construct($username, $password) {
40
		$this->_username = $username;
41
		$this->_password = $password;
42
	}
43
	
44
	public function getBody(){
45
		$body = pack('C', 0);
46
		$body .= $this->_username;
47
		$body .= pack('C', 0);
48
		$body .= $this->_password;
49
		
50
		return pack('N', strlen($body)) . $body;
51
	}
52
	
53
}
54