Passed
Push — v1 ( 4e4d0c...0eb06a )
by Andrew
12:54 queued 07:50
created

InfoController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A actionIsLive() 0 3 1
A actionLiveViewers() 0 3 1
1
<?php
2
/**
3
 * YouTube Live Embed plugin for Craft CMS 3.x
4
 *
5
 * This plugin allows you to embed a YouTube live stream and/or live chat on your webpage
6
 *
7
 * @link      https://nystudio107.com
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
8
 * @copyright Copyright (c) 2019 nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
9
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
10
11
namespace nystudio107\youtubeliveembed\controllers;
12
13
use nystudio107\youtubeliveembed\YoutubeLiveEmbed;
14
15
use Craft;
16
use craft\web\Controller;
17
18
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
19
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 4
Loading history...
20
 * @package   YoutubeLiveEmbed
0 ignored issues
show
Coding Style introduced by
Tag value indented incorrectly; expected 1 spaces but found 3
Loading history...
21
 * @since     1.0.0
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 3 spaces but found 5
Loading history...
22
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
23
class InfoController extends Controller
24
{
25
    // Protected Properties
26
    // =========================================================================
27
28
    protected $allowAnonymous = [
29
        'is-live',
30
        'live-viewers',
31
    ];
32
33
    // Public Methods
34
    // =========================================================================
35
36
37
    /**
38
     * Returns whether the stream is currently live
39
     *
40
     * @return bool
41
     */
42
    public function actionIsLive(): bool
43
    {
44
        return YoutubeLiveEmbed::$plugin->embed->isLive();
45
    }
46
47
    /**
48
     * Returns the number of people currently viewing the live stream
49
     *
50
     * @return int
51
     */
52
    public function actionLiveViewers(): int
53
    {
54
        return YoutubeLiveEmbed::$plugin->embed->liveViewers();
55
    }
56
}
57