Test Failed
Branch master (74d1c9)
by Seth
34:11 queued 23:36
created

StMarksSmarty::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 3
b 0
f 0
nc 1
nop 4
dl 0
loc 8
rs 10
1
<?php
2
3
/** StMarksSmarty and related classes */
4
5
namespace smtech\StMarksSmarty;
6
7
use Battis\BootstrapSmarty\BootstrapSmarty;
8
use Battis\DataUtilities;
9
10
/**
11
 * A wrapper for Smarty to set (and maintain) defaults
12
 *
13
 * @author Seth Battis <[email protected]>
14
 **/
15
class StMarksSmarty extends BootstrapSmarty
16
{
17
    /**
18
     * Identifier for UI layer provided by this class
19
     */
20
    const KEY = 'StMarks-BootstrapSmarty';
21
22
    /**
23
     * Is this app presented inside of an `iframe`?
24
     * @var boolean
25
     */
26
    private $isFramed = false;
27
28
    /**
29
     * @inheritDoc
30
     *
31
     * @param string $template
32
     * @param string $config
33
     * @param string $compile
34
     * @param string $cache
35
     * @return StMarksSmarty
36
     */
37
    public static function getSmarty($template = null, $config = null, $compile = null, $cache = null)
38
    {
39
        if (self::$singleton === null) {
40
            self::$singleton = new self($template, $config, $compile, $cache);
41
        }
42
        return self::$singleton;
43
    }
44
45
    /**
46
     * @inheritDoc
47
     *
48
     * @param string $template
49
     * @param string $config
50
     * @param string $compile
51
     * @param string $cache
52
     */
53
    public function __construct($template = null, $config = null, $compile = null, $cache = null)
54
    {
55
        parent::__construct($template, $config, $compile, $cache);
0 ignored issues
show
Deprecated Code introduced by
The function Battis\BootstrapSmarty\B...apSmarty::__construct() has been deprecated: Use singleton pattern BootstrapSmarty::getSmarty() ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
        /** @scrutinizer ignore-deprecated */ parent::__construct($template, $config, $compile, $cache);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
56
57
        $this->prependTemplateDir(__DIR__ . '/../templates', self::KEY);
58
        $this->addStylesheet(
59
            DataUtilities::URLfromPath(__DIR__ . '/../css/StMarksSmarty.css'),
0 ignored issues
show
Bug introduced by
It seems like Battis\DataUtilities::UR...css/StMarksSmarty.css') can also be of type false; however, parameter $stylesheet of Battis\BootstrapSmarty\B...Smarty::addStylesheet() does only seem to accept string|string[], maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

59
            /** @scrutinizer ignore-type */ DataUtilities::URLfromPath(__DIR__ . '/../css/StMarksSmarty.css'),
Loading history...
60
            self::KEY
61
        );
62
    }
63
64
    /**
65
     * Set whether or not this app is in an `iframe`
66
     *
67
     * @param boolean $isFramed
68
     */
69
    public function setFramed($isFramed)
70
    {
71
        $this->isFramed = (bool) $isFramed;
72
    }
73
74
    /**
75
     * Is this app presented in an `iframe`?
76
     *
77
     * @return boolean
78
     */
79
    public function isFramed()
80
    {
81
        return $this->isFramed;
82
    }
83
84
    /**
85
     * @inheritDoc
86
     *
87
     * @param string $template
88
     * @param string $cache_id
89
     * @param string $compile_id
90
     * @param string $parent
91
     * @return void
92
     */
93
    public function display($template = 'page.tpl', $cache_id = null, $compile_id = null, $parent = null)
94
    {
95
        if ($this->isFramed()) {
96
            $this->addStylesheet(
97
                DataUtilities::URLfromPath(__DIR__ . '/../css/StMarksSmarty.css') . '?isFramed=true',
0 ignored issues
show
Bug introduced by
Are you sure Battis\DataUtilities::UR...css/StMarksSmarty.css') of type false|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

97
                /** @scrutinizer ignore-type */ DataUtilities::URLfromPath(__DIR__ . '/../css/StMarksSmarty.css') . '?isFramed=true',
Loading history...
98
                self::KEY
99
            );
100
        }
101
        $this->assign('isFramed', $this->isFramed());
102
103
        parent::display($template, $cache_id, $compile_id, $parent);
104
    }
105
}
106