Failed Conditions
Push — master ( e7d024...c4faa1 )
by Andreas
82:44 queued 20s
created

DisplayTile::show()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 23
rs 9.552
c 0
b 0
f 0
1
<?php
2
3
namespace dokuwiki\Ui\Media;
4
5
use dokuwiki\File\MediaFile;
6
7
/**
8
 * Display a MediaFile in the FullScreen MediaManager
9
 */
10
class DisplayTile extends Display
11
{
12
    /** @var string URL to open this file in the media manager */
13
    protected $mmUrl;
14
15
    /** @inheritDoc */
16
    public function __construct(MediaFile $mediaFile)
17
    {
18
        parent::__construct($mediaFile);
19
20
        // FIXME we may want to integrate this function here or in another class
21
        $this->mmUrl = media_managerURL([
0 ignored issues
show
Documentation Bug introduced by
It seems like media_managerURL(array('...ab_details' => 'view')) can also be of type array. However, the property $mmUrl is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
22
            'image' => $this->mediaFile->getId(),
23
            'ns' => getNS($this->mediaFile->getId()),
24
            'tab_details' => 'view',
25
        ]);
26
    }
27
28
    /**
29
     * Display the tile
30
     */
31
    public function show()
32
    {
33
        $jump = $this->scrollIntoView ? 'id="scroll__here"' : '';
34
35
        echo '<dl title="' . $this->mediaFile->getDisplayName() . '"' . $jump . '>';
36
        echo '<dt>';
37
        echo '<a id="l_:' . $this->mediaFile->getId() . '" class="image thumb" href="' . $this->mmUrl . '">';
38
        echo $this->getPreviewHtml(90, 90);
39
        echo '</a>';
40
        echo '</dt>';
41
42
        echo '<dd class="name">';
43
        echo '<a href="' . $this->mmUrl . '" id="h_:' . $this->mediaFile->getId() . '">' .
44
            $this->formatDisplayName() .
45
            '</a>';
46
        echo '</dd>';
47
48
        echo '<dd class="size">' . $this->formatDimensions() . '</dd>';
49
        echo '<dd class="date">' . $this->formatDate() . '</dd>';
50
        echo '<dd class="filesize">' . $this->formatFileSize() . '</dd>';
51
52
        echo '</dl>';
53
    }
54
}
55