ContinuationFrame   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 63
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A serializeBody() 0 4 1
A parseBody() 0 5 1
A setData() 0 6 1
A getData() 0 4 1
1
<?php
2
declare(strict_types=1);
3
namespace Hyphper\Frame;
4
5
/**
6
 * The CONTINUATION frame is used to continue a sequence of header block
7
 * fragments. Any number of CONTINUATION frames can be sent on an existing
8
 * stream, as long as the preceding frame on the same stream is one of
9
 * HEADERS, PUSH_PROMISE or CONTINUATION without the END_HEADERS flag set.
10
 * Much like the HEADERS frame, hyper treats this as an opaque data frame with
11
 * different flags and a different type.
12
 *
13
 * @package Hyphper\Frame
14
 */
15
class ContinuationFrame extends \Hyphper\Frame
16
{
17
    protected $defined_flags = [Flag::END_HEADERS];
18
    protected $type = 0x09;
19
    protected $stream_association = self::HAS_STREAM;
20
    protected $data;
21
22
    /**
23
     * ContinuationFrame constructor.
24
     *
25
     * @param array $options
26
     */
27 3
    public function __construct(array $options = [])
28
    {
29 3
        parent::__construct($options);
30
31 3
        $this->data = $options['data'] ?? '';
32 3
    }
33
34
    /**
35
     * @return string
36
     */
37 1
    public function serializeBody(): string
38
    {
39 1
        return $this->data;
40
    }
41
42
    /**
43
     * Given the body of a frame, parses it into frame data. This populates
44
     * the non-header parts of the frame: that is, it does not populate the
45
     * stream ID or flags.
46
     *
47
     *
48
     * @param string $data
49
     *
50
     * @return void
51
     */
52 1
    public function parseBody(string $data)
53
    {
54 1
        $this->data = $data;
55 1
        $this->body_len = strlen($data);
56 1
    }
57
58
    /**
59
     * @param mixed|string $data
60
     *
61
     * @return ContinuationFrame
62
     */
63 1
    public function setData($data)
64
    {
65 1
        $this->data = $data;
66
67 1
        return $this;
68
    }
69
70
    /**
71
     * @return mixed|string
72
     */
73 1
    public function getData()
74
    {
75 1
        return $this->data;
76
    }
77
}
78