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

SecuredTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A isSecured() 0 11 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