Completed
Push — master ( 5d604f...33b193 )
by Craig
07:57
created

FincludeBlock::getFormOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Zikula package.
5
 *
6
 * Copyright Zikula Foundation - http://zikula.org/
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zikula\BlocksModule\Block;
13
14
use Zikula\BlocksModule\AbstractBlockHandler;
15
16
/**
17
 * Block to display the contents of a file given a path.
18
 */
19
class FincludeBlock extends AbstractBlockHandler
20
{
21
    public function display(array $properties)
22
    {
23
        if (!$this->hasPermission('fincludeblock::', "$properties[title]::", ACCESS_READ)) {
24
            return '';
25
        }
26
27
        switch ($properties['typo']) {
28
            case 0: // Html
29
                return file_get_contents($properties['filo']);
30
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
31
            case 1: // Text
32
                return htmlspecialchars(file_get_contents($properties['filo']));
33
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
34
            case 2: // PHP
35
                ob_start();
36
                include \DataUtil::formatForOS($properties['filo']);
37
38
                return ob_get_clean();
39
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
40
            default:
41
                return '';
42
        }
43
    }
44
45
    public function getFormClassName()
46
    {
47
        return 'Zikula\BlocksModule\Block\Form\Type\FincludeBlockType';
48
    }
49
50
    public function getFormOptions()
51
    {
52
        return ['translator' => $this->getTranslator()];
53
    }
54
55
    public function getType()
56
    {
57
        return $this->__("File Include");
58
    }
59
}
60