Passed
Push — master ( 673916...a119ad )
by
unknown
02:00
created

src/Jobs/CheckExternalLinksJob.php (6 issues)

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 17 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace SilverStripe\ExternalLinks\Jobs;
4
5
use Symbiote\QueuedJobs\Services\AbstractQueuedJob;
0 ignored issues
show
The type Symbiote\QueuedJobs\Services\AbstractQueuedJob was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Symbiote\QueuedJobs\Services\QueuedJob;
0 ignored issues
show
The type Symbiote\QueuedJobs\Services\QueuedJob was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use SilverStripe\ExternalLinks\Tasks\CheckExternalLinksTask;
8
9
if (!class_exists(AbstractQueuedJob::class)) {
10
    return;
11
}
12
13
/**
14
 * A Job for running a external link check for published pages
15
 *
16
 */
17
class CheckExternalLinksJob extends AbstractQueuedJob implements QueuedJob
18
{
19
20
    public function getTitle()
21
    {
22
        return _t(__CLASS__ . '.TITLE', 'Checking for external broken links');
23
    }
24
25
    public function getJobType()
26
    {
27
        return QueuedJob::QUEUED;
28
    }
29
30
    public function getSignature()
31
    {
32
        return md5(get_class($this));
33
    }
34
35
    /**
36
     * Check an individual page
37
     */
38
    public function process()
39
    {
40
        $task = CheckExternalLinksTask::create();
41
        $track = $task->runLinksCheck(1);
42
        $this->currentStep = $track->CompletedPages;
0 ignored issues
show
Bug Best Practice introduced by
The property currentStep does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
43
        $this->totalSteps = $track->TotalPages;
0 ignored issues
show
Bug Best Practice introduced by
The property totalSteps does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
44
        $this->isComplete = $track->Status === 'Completed';
0 ignored issues
show
Bug Best Practice introduced by
The property isComplete does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
45
    }
46
}
47