Passed
Push — v1 ( 63c526...da15fc )
by Andrew
08:26 queued 05:04
created

src/variables/WebperfVariable.php (1 issue)

1
<?php
2
/**
3
 * Webperf plugin for Craft CMS 3.x
4
 *
5
 * Monitor the performance of your webpages through real-world user timing data
6
 *
7
 * @link      https://nystudio107.com
8
 * @copyright Copyright (c) 2019 nystudio107
9
 */
10
11
namespace nystudio107\webperf\variables;
12
13
use nystudio107\webperf\Webperf;
14
15
/**
16
 * @author    nystudio107
17
 * @package   Webperf
18
 * @since     1.0.0
19
 */
20
class WebperfVariable extends ManifestVariable
21
{
22
    // Public Methods
23
    // =========================================================================
24
25
    /**
26
     * Whether to include the beacon or not
27
     *
28
     * @param bool $include
29
     */
30
    public function includeBeacon(bool $include)
31
    {
32
        Webperf::$settings->includeBeacon = $include;
33
    }
34
35
    /**
36
     * Whether to include the Craft beacon or not
37
     *
38
     * @param bool $include
39
     */
40
    public function includeCraftBeacon(bool $include)
41
    {
42
        Webperf::$settings->includeCraftProfiling = $include;
43
    }
44
45
    /**
46
     * Change the type of render; either `html` or `amp-html` are valid for $renderType
47
     *
48
     * @param string $renderType
49
     */
50
    public function renderType(string $renderType)
51
    {
52
        Webperf::$renderType = $renderType;
53
    }
54
55
    /**
56
     * @param int    $siteId
57
     * @param string $column
58
     *
59
     * @return int|string
60
     */
61
    public function totalSamples(int $siteId, string $column)
62
    {
63
        return Webperf::$plugin->dataSamples->totalSamples($siteId, $column);
64
    }
65
66
    /**
67
     * Get the total number of errors optionally limited by siteId, between
68
     * $start and $end
69
     *
70
     * @param int         $siteId
71
     * @param string      $start
72
     * @param string      $end
73
     * @param string|null $pageUrl
0 ignored issues
show
Missing parameter comment
Loading history...
74
     * @param string|null $type
75
     *
76
     * @return int
77
     */
78
    public function totalErrorSamplesRange(int $siteId, string $start, string $end, $pageUrl = null, $type = null): int
79
    {
80
        return Webperf::$plugin->errorSamples->totalErrorSamplesRange($siteId, $start, $end, $pageUrl, $type);
81
    }
82
83
    /**
84
     * Return whether we are running Craft 3.1 or later
85
     *
86
     * @return bool
87
     */
88
    public function craft31(): bool
89
    {
90
        return Webperf::$craft31;
91
    }
92
}
93