Passed
Branch master (8d4084)
by Antony
03:09 queued 01:05
created

UnleashedBuildTask   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A log() 0 8 3
1
<?php
2
3
namespace AntonyThorpe\SilverShopUnleashed\Task;
4
5
use GuzzleHttp\Exception\RequestException;
6
use Psr\Http\Message\ResponseInterface;
7
use SilverStripe\Control\Controller;
8
use SilverStripe\Control\Director;
9
use SilverStripe\Dev\BuildTask;
10
use SilverStripe\ORM\DatabaseAdmin;
11
use SilverStripe\ORM\DB;
12
13
/**
14
 * Base BuildTask for Unleashed Software
15
 */
16
abstract class UnleashedBuildTask extends BuildTask
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $email_subject = "API Unleashed Software";
22
23
    /**
24
     * @var boolean
25
     */
26
    protected $preview = false;
27
28
    /**
29
     * echo to screen for Build Reports
30
     * @param  string $text the message to be printed
31
     */
32
    protected function log($text)
33
    {
34
        if (Controller::curr() instanceof DatabaseAdmin) {
35
            DB::alteration_message($text, 'obsolete');
36
        } elseif (Director::is_cli()) {
37
            echo $text . "\n";
38
        } else {
39
            echo $text . "<br/>";
40
        }
41
    }
42
}
43