Completed
Pull Request — develop (#61)
by Kevin
09:23
created

ViewConfiguration::setBootstrapCssUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Magium\Configuration\View;
4
5
use Psr\Http\Message\MessageInterface;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
9
class ViewConfiguration
10
{
11
12
    protected $request;
13
    protected $response;
14
    protected $layoutFile;
15
    protected $viewDirectory;
16
    protected $viewFile;
17
    protected $jqueryUrl;
18
    protected $provideWrapperHtml;
19
    protected $bootstrapJsUrl;
20
    protected $bootstrapCssUrl;
21
22
    /**
23
     * ViewConfiguration constructor.
24
     * @param ServerRequestInterface $request
25
     * @param MessageInterface $response
26
     * @param string $viewDirectory
27
     * @param string $layoutFile
28
     * @param string $viewFile
29
     * @param boolean $provideWrapperHtml
30
     * @param boolean $provideJqueryUrl
0 ignored issues
show
Documentation introduced by
There is no parameter named $provideJqueryUrl. Did you maybe mean $jqueryUrl?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
31
     * @throws InvalidViewConfigurationException
32
     */
33 22
    public function __construct(
34
        ServerRequestInterface $request,
35
        MessageInterface $response,
36
        $viewDirectory = __DIR__ . '/views' ,
37
        $layoutFile = 'layout.phtml',
38
        $viewFile = 'view.phtml',
39
        $provideWrapperHtml = true,
40
        $jqueryUrl = 'https://code.jquery.com/jquery-3.2.1.min.js',
41
        $bootstrapJsUrl = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js',
42
        $bootstrapCssUrl = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'
43
    )
44
    {
45 22
        $this->setRequest($request);
46 22
        $this->setResponse($response);
47 22
        $this->setViewDirectory($viewDirectory);
48 21
        $this->setLayoutFile($layoutFile);
49 20
        $this->setViewFile($viewFile);
50 19
        $this->setProvideWrapperHtml($provideWrapperHtml);
51 19
        $this->setJqueryUrl($jqueryUrl);
0 ignored issues
show
Documentation introduced by
$jqueryUrl is of type string, but the function expects a boolean.

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...
52 19
        $this->setBootstrapJsUrl($bootstrapJsUrl);
53 19
        $this->setBootstrapCssUrl($bootstrapCssUrl);
54 19
    }
55
56
    /**
57
     * @return mixed
58
     */
59 8
    public function getBootstrapCssUrl()
60
    {
61 8
        return $this->bootstrapCssUrl;
62
    }
63
64
    /**
65
     * @param mixed $bootstrapCssUrl
66
     */
67 19
    public function setBootstrapCssUrl($bootstrapCssUrl)
68
    {
69 19
        $this->bootstrapCssUrl = $bootstrapCssUrl;
70 19
    }
71
72
    /**
73
     * @return mixed
74
     */
75 8
    public function getBootstrapJsUrl()
76
    {
77 8
        return $this->bootstrapJsUrl;
78
    }
79
80
    /**
81
     * @param mixed $bootstrapJsUrl
82
     */
83 19
    public function setBootstrapJsUrl($bootstrapJsUrl)
84
    {
85 19
        $this->bootstrapJsUrl = $bootstrapJsUrl;
86 19
    }
87
88
89
90
    /**
91
     * @return mixed
92
     */
93 8
    public function getProvideWrapperHtml()
94
    {
95 8
        return $this->provideWrapperHtml;
96
    }
97
98
    /**
99
     * @param mixed $provideWrapperHtml
100
     */
101 19
    public function setProvideWrapperHtml($provideWrapperHtml)
102
    {
103 19
        $this->provideWrapperHtml = $provideWrapperHtml;
104 19
    }
105
106
    /**
107
     * @return ServerRequestInterface
108
     */
109 1
    public function getRequest()
110
    {
111 1
        return $this->request;
112
    }
113
114
    /**
115
     * @param ServerRequestInterface $request
116
     */
117 22
    public function setRequest(ServerRequestInterface $request)
118
    {
119 22
        $this->request = $request;
120 22
    }
121
122
    /**
123
     * @return ResponseInterface
124
     */
125 1
    public function getResponse()
126
    {
127 1
        return $this->response;
128
    }
129
130
    /**
131
     * @param MessageInterface $response
132
     */
133 22
    public function setResponse(MessageInterface $response)
134
    {
135 22
        $this->response = $response;
136 22
    }
137
138
    /**
139
     * @return string
140
     */
141 8
    public function getLayoutFile()
142
    {
143 8
        return $this->layoutFile;
144
    }
145
146
    /**
147
     * @param string $layoutFile
148
     * @throws InvalidViewConfigurationException
149
     */
150 21 View Code Duplication
    public function setLayoutFile($layoutFile)
151
    {
152 21
        $this->layoutFile = realpath($this->getViewDirectory() . DIRECTORY_SEPARATOR . $layoutFile);
153 21
        if (!is_file($this->layoutFile)) {
154 1
            throw new InvalidViewConfigurationException('Could not resolve base layout file: ' . $layoutFile);
155
        }
156 20
        $this->layoutFile = basename($this->layoutFile);
157 20
    }
158
159
    /**
160
     * @return string
161
     */
162 21
    public function getViewDirectory()
163
    {
164 21
        return $this->viewDirectory;
165
    }
166
167
    /**
168
     * @param string $viewDirectory
169
     * @throws InvalidViewConfigurationException
170
     */
171 22
    public function setViewDirectory($viewDirectory)
172
    {
173 22
        $this->viewDirectory = realpath($viewDirectory);
174 22
        if (!is_dir($this->viewDirectory)) {
175 1
            throw new InvalidViewConfigurationException('Could not resolve base view directory: ' . $viewDirectory);
176
        }
177 21
    }
178
179
    /**
180
     * @return string
181
     */
182 1
    public function getViewFile()
183
    {
184 1
        return $this->viewFile;
185
    }
186
187
    /**
188
     * @param string $viewFile
189
     * @throws InvalidViewConfigurationException
190
     */
191 20 View Code Duplication
    public function setViewFile($viewFile)
192
    {
193 20
        $this->viewFile = realpath($this->getViewDirectory() . DIRECTORY_SEPARATOR . $viewFile);
194 20
        if (!is_file($this->viewFile)) {
195 1
            throw new InvalidViewConfigurationException('Could not resolve base file file: ' . $viewFile);
196
        }
197 19
        $this->viewFile = basename($this->viewFile);
198 19
    }
199
200
    /**
201
     * @return bool
202
     */
203 8
    public function getJqueryUrl()
204
    {
205 8
        return $this->jqueryUrl;
206
    }
207
208
    /**
209
     * @param bool $jqueryUrl
210
     */
211 19
    public function setJqueryUrl($jqueryUrl)
212
    {
213 19
        $this->jqueryUrl = $jqueryUrl;
214 19
    }
215
216
217
218
219
}
220