EmailReminder_Mailer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A sendHTML() 0 29 3
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