BaseLongPollAction::runInternal()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @link https://github.com/Izumi-kun/yii2-longpoll
4
 * @copyright Copyright (c) 2017 Viktor Khokhryakov
5
 * @license http://opensource.org/licenses/BSD-3-Clause
6
 */
7
8
namespace izumi\longpoll;
9
10
use Yii;
11
use yii\base\Action;
12
use yii\web\Response;
13
14
/**
15
 * Base class for long poll actions.
16
 * Please extend this class for creating complex actions.
17
 * @author Viktor Khokhryakov <[email protected]>
18
 */
19
class BaseLongPollAction extends Action
20
{
21
    /**
22
     * @var array
23
     */
24
    public $events;
25
    /**
26
     * @var callable
27
     */
28
    public $callback;
29
    /**
30
     * @var string
31
     */
32
    public $serverClass = Server::class;
33
34
    /**
35
     * @return Response
36
     * @throws \yii\base\InvalidConfigException
37
     */
38 1
    protected function runInternal()
39
    {
40
        /** @var Server $server */
41 1
        $server = Yii::createObject([
42 1
            'class' => $this->serverClass,
43 1
            'events' => $this->events,
44 1
            'callback' => $this->callback,
45
        ]);
46
47 1
        return $server;
48
    }
49
}
50