Completed
Push — master ( 622c37...dca855 )
by Christian
04:12
created

SelfTestCalledViaHttps   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A doTest() 0 14 2
1
<?php
2
3
/**
4
 * This file is part of tenside/core.
5
 *
6
 * (c) Christian Schiffler <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * This project is provided in good faith and hope to be usable by anyone.
12
 *
13
 * @package    tenside/core
14
 * @author     Christian Schiffler <[email protected]>
15
 * @copyright  2015 Christian Schiffler <[email protected]>
16
 * @license    https://github.com/tenside/core/blob/master/LICENSE MIT
17
 * @link       https://github.com/tenside/core
18
 * @filesource
19
 */
20
21
namespace Tenside\Core\SelfTest\Generic;
22
23
use Symfony\Component\HttpFoundation\Request;
24
use Tenside\Core\SelfTest\AbstractSelfTest;
25
26
/**
27
 * This class tests that we are in secure environment.
28
 */
29
class SelfTestCalledViaHttps extends AbstractSelfTest
30
{
31
    /**
32
     * Check that we are being called via HTTPS in favor of HTTP.
33
     *
34
     * @return void
35
     */
36
    protected function doTest()
37
    {
38
        $this->setMessage('Check that HTTPS is used instead of HTTP.');
39
40
        $request = Request::createFromGlobals();
41
42
        if ($request->isSecure()) {
43
            $this->markSuccess();
44
45
            return;
46
        }
47
48
        $this->markWarning('HTTPS is not used.');
49
    }
50
}
51