Completed
Push — master ( 5f1ca1...a7b5ff )
by Henry
04:31
created

Cache   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 24
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A autorun() 0 15 4
1
<?php
2
namespace Redaxscript\Bootstrap;
3
4
use Redaxscript\Filter;
5
use function getenv;
6
7
/**
8
 * children class to boot the cache
9
 *
10
 * @since 3.1.0
11
 *
12
 * @package Redaxscript
13
 * @category Bootstrap
14
 * @author Henry Ruhs
15
 */
16
17
class Cache extends BootstrapAbstract
18
{
19
	/**
20
	 * automate run
21
	 *
22
	 * @since 3.1.0
23
	 */
24
25 3
	public function autorun() : void
26
	{
27 3
		$filterBoolean = new Filter\Boolean();
28 3
		$noCache = $filterBoolean->sanitize($this->_request->getQuery('no-cache')) || getenv('NO_CACHE');
0 ignored issues
show
Bug introduced by
It seems like $this->_request->getQuery('no-cache') targeting Redaxscript\Request::getQuery() can also be of type array; however, Redaxscript\Filter\Boolean::sanitize() does only seem to accept boolean|string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
29
30
		/* set the registry */
31
32 3
		$this->_registry->set('noAssetCache', false);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string|array|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...
33 3
		$this->_registry->set('noPageCache', false);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string|array|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...
34 3
		if ($this->_registry->get('loggedIn') === $this->_registry->get('token') || $noCache)
35
		{
36 2
			$this->_registry->set('noAssetCache', true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a string|array|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...
37 2
			$this->_registry->set('noPageCache', true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a string|array|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...
38
		}
39 3
	}
40
}
41