Failed Conditions
Push — refactorSubscriptions ( 75d664...451969 )
by Michael
07:30 queued 03:08
created

MediaSubscriptionSender::sendMediaDiff()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 4
dl 0
loc 26
rs 9.504
c 0
b 0
f 0
1
<?php
2
3
4
namespace dokuwiki\Subscriptions;
5
6
7
class MediaSubscriptionSender extends SubscriptionSender
8
{
9
10
    /**
11
     * Send the diff for some media change
12
     *
13
     * @fixme this should embed thumbnails of images in HTML version
14
     *
15
     * @param string   $subscriber_mail The target mail address
16
     * @param string   $template        Mail template ('uploadmail', ...)
17
     * @param string   $id              Media file for which the notification is
18
     * @param int|bool $rev             Old revision if any
19
     */
20
    public function sendMediaDiff($subscriber_mail, $template, $id, $rev = false)
21
    {
22
        global $conf;
23
24
        $file = mediaFN($id);
25
        list($mime, /* $ext */) = mimetype($id);
26
27
        $trep = [
28
            'MIME' => $mime,
29
            'MEDIA' => ml($id, '', true, '&', true),
30
            'SIZE' => filesize_h(filesize($file)),
31
        ];
32
33
        if ($rev && $conf['mediarevisions']) {
34
            $trep['OLD'] = ml($id, "rev=$rev", true, '&', true);
35
        } else {
36
            $trep['OLD'] = '---';
37
        }
38
39
        $headers = ['Message-Id' => $this->getMessageID($id, @filemtime($file))];
40
        if ($rev) {
41
            $headers['In-Reply-To'] = $this->getMessageID($id, $rev);
0 ignored issues
show
Documentation introduced by
$rev is of type integer|boolean, but the function expects a string|null.

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...
42
        }
43
44
        $this->send($subscriber_mail, 'upload', $id, $template, $trep, null, $headers);
45
    }
46
}
47