Eventsource   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sendFrame() 0 5 1
A init() 0 8 2
1
<?php
2
namespace PHPDaemon\SockJS\Methods;
3
4
/**
5
 * @package    Libraries
6
 * @subpackage SockJS
7
 * @author     Vasily Zorin <[email protected]>
8
 */
9
class Eventsource extends Generic
10
{
11
    protected $contentType = 'text/event-stream';
12
    protected $poll = true;
13
    protected $pollMode = ['stream'];
14
    protected $gcEnabled = true;
15
16
    /**
17
     * Send frame
18
     * @param  string $frame
19
     * @return void
20
     */
21
    public function sendFrame($frame)
22
    {
23
        $this->outputFrame('data: ' . $frame . "\r\n\r\n");
24
        parent::sendFrame($frame);
25
    }
26
27
    /**
28
     * Constructor
29
     * @return void
30
     */
31
    public function init()
32
    {
33
        parent::init();
34
        if ($this->isFinished()) {
35
            return;
36
        }
37
        $this->out("\r\n", false);
38
    }
39
}
40