Completed
Push — master ( 7f78e2...8137fc )
by
unknown
01:34
created

EmailReminder_Mailer::sendHTML()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 29
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 8.8571
c 0
b 0
f 0
cc 3
eloc 24
nc 3
nop 7
1
<?php
2
3
4
class EmailReminder_Mailer extends Mailer
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
5
{
6
    private static $css_file = 'email_reminder/css/example.css';
0 ignored issues
show
Unused Code introduced by
The property $css_file is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
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