Passed
Push — developer ( db306d...128070 )
by Mariusz
105:17 queued 70:07
created

RequestUtil   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isHttps() 0 8 5
1
<?php
2
/**
3
 * Request Utils basic file.
4
 *
5
 * @package App
6
 *
7
 * @copyright YetiForce Sp. z o.o
8
 * @license   YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Mariusz Krzaczkowski <[email protected]>
10
 */
11
12
namespace App;
13
14
/**
15
 * Request Utils basic class.
16
 */
17
class RequestUtil
18
{
19
	/**
20
	 * Cache https check variable.
21
	 *
22
	 * @var bool
23
	 */
24
	protected static $httpsCache;
25
26
	/**
27
	 * Check that the connection is https.
28
	 *
29
	 * @return bool
30
	 */
31
	public static function isHttps(): bool
32
	{
33
		if (!isset(self::$httpsCache)) {
34
			self::$httpsCache = (!empty($_SERVER['HTTPS']) && 'off' !== strtolower($_SERVER['HTTPS']))
35
				|| (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && 'https' === strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']));
36
		}
37
		return self::$httpsCache;
38
	}
39
}
40