Frame::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 5
1
<?php
2
namespace evseevnn\Cassandra\Protocol;
3
4
class Frame {
5
6
	/**
7
	 * @var int
8
	 */
9
	private $version;
10
11
	/**
12
	 * @var int
13
	 */
14
	private $opcode;
15
16
	/**
17
	 * @var string
18
	 */
19
	private $body;
20
21
	/**
22
	 * @var int
23
	 */
24
	private $stream;
25
26
	/**
27
	 * @var int
28
	 */
29
	private $flags;
30
31
	/**
32
	 * @param int $version
33
	 * @param int $opcode
34
	 * @param string $body
35
	 * @param int $stream
36
	 * @param int $flags
37
	 */
38
	public function __construct($version, $opcode, $body, $stream = 0, $flags = 0) {
39
		$this->version = $version;
40
		$this->opcode = $opcode;
41
		$this->body = $body;
42
		$this->stream = $stream;
43
		$this->flags = $flags;
44
	}
45
46
	/**
47
	 * @return string
48
	 */
49
	public function __toString() {
50
		return pack(
51
			'CCcCN',
52
			$this->version,
53
			$this->flags,
54
			$this->stream,
55
			$this->opcode,
56
			strlen($this->body)
57
		) . $this->body;
58
	}
59
}