Passed
Push — master ( 4fcf6f...e67987 )
by Jan
03:06
created

SecuredTrait::isSecured()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.2
cc 4
eloc 6
nc 6
nop 1
crap 4
1
<?php
2
3
/**
4
 * This file is part of Lekarna.cz (http://www.lekarna.cz/)
5
 *
6
 * Copyright (c) 2014 Pears Health Cyber, s.r.o. (http://pearshealthcyber.cz)
7
 *
8
 * For the full copyright and license information, please view
9
 * the file LICENSE that was distributed with this source code.
10
 */
11
12
namespace App;
13
14
use Slim\Http\Request;
15
16
17
trait SecuredTrait
18
{
19
20
	/**
21
	 * @param Request $request
22
	 * @return bool
23
	 */
24 13
	private function isSecured(Request $request)
25
	{
26 13
		$secured = FALSE;
27 13
		foreach ($request->getHeader(self::SECRET_HEADER) as $secret) {
28 11
			if ($secret == $this->secret) { // allow cast
0 ignored issues
show
Bug introduced by
The property secret does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29 11
				$secured = TRUE;
30 11
			}
31 13
		}
32
33 13
		return $this->secret === NULL || $secured;
34
	}
35
36
}
37