Passed
Push — v3 ( 177c2d...bd0cd1 )
by Andrew
15:58 queued 07:14
created

Queue   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 21 5
1
<?php
2
/**
3
 * SEOmatic plugin for Craft CMS 3.x
4
 *
5
 * A turnkey SEO implementation for Craft CMS that is comprehensive, powerful,
6
 * and flexible
7
 *
8
 * @link      https://nystudio107.com
9
 * @copyright Copyright (c) 2017 nystudio107
10
 */
11
12
namespace nystudio107\seomatic\helpers;
13
14
use nystudio107\seomatic\Seomatic;
15
16
use Craft;
17
use craft\helpers\App;
18
use craft\queue\QueueInterface;
19
20
/**
21
 * @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...
22
 * @package   Seomatic
23
 * @since     3.2.16
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
24
 */
25
class Queue
26
{
27
    // Constants
28
    // =========================================================================
29
30
    // Static Methods
31
    // =========================================================================
32
33
    /**
34
     * Run the queue if we can run it via the web interface
35
     *
36
     * @return void
37
     */
38
    public static function run()
39
    {
40
        $queue = Craft::$app->getQueue();
41
        // Make sure the queue uses the Craft web interface
42
        if (!$queue instanceof QueueInterface) {
0 ignored issues
show
introduced by
$queue is always a sub-type of craft\queue\QueueInterface.
Loading history...
43
            return;
44
        }
45
46
        // Make sure Craft is configured to run queues over the web
47
        if (!Craft::$app->getConfig()->getGeneral()->runQueueAutomatically) {
48
            return;
49
        }
50
51
        // Make sure the queue isn't already running, and there are waiting jobs
52
        if ($queue->getHasReservedJobs() || !$queue->getHasWaitingJobs()) {
53
            return;
54
        }
55
56
        // Run the queue
57
        App::maxPowerCaptain();
58
        $queue->run();
59
    }
60
}
61