EmailReminder_Mailer::sendHTML()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 9.456
c 0
b 0
f 0
cc 3
nc 3
nop 7
1
<?php
2
3
4
class EmailReminder_Mailer extends Mailer
5
{
6
    private static $css_file = 'email_reminder/css/example.css';
7
8
    public function sendHTML(
9
        $to,
10
        $from,
11
        $subject,
12
        $htmlContent,
13
        $attachedFiles = false,
14
        $customheaders = false,
15
        $plainContent = false
16
    ) {
17
        $cssFileLocation = Director::baseFolder() .'/'. Config::inst()->get("EmailReminder_Mailer", "css_file");
18
        if ($cssFileLocation) {
19
            if (file_exists($cssFileLocation)) {
20
                $cssFileHandler = fopen($cssFileLocation, 'r');
21
                $css = fread($cssFileHandler, filesize($cssFileLocation));
22
                fclose($cssFileHandler);
23
                $emog = new \Pelago\Emogrifier($htmlContent, $css);
24
                $htmlContent = $emog->emogrify();
25
            }
26
        }
27
        return parent::sendHTML(
28
            $to,
29
            $from,
30
            $subject,
31
            $htmlContent,
32
            $attachedFiles,
0 ignored issues
show
Documentation introduced by
$attachedFiles is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
            $customheaders,
0 ignored issues
show
Documentation introduced by
$customheaders is of type boolean, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
34
            $plainContent
0 ignored issues
show
Documentation introduced by
$plainContent is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
        );
36
    }
37
}
38