ServerRequirementsComposer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 6
eloc 13
dl 0
loc 62
ccs 0
cts 15
cp 0
rs 10
c 6
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A checkSslInstalled() 0 3 3
A compose() 0 8 1
A getServerModules() 0 11 2
1
<?php namespace Arcanesoft\Foundation\ViewComposers\System;
2
3
use Illuminate\View\View;
0 ignored issues
show
Bug introduced by
The type Illuminate\View\View was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
5
/**
6
 * Class     ServerRequirementsComposer
7
 *
8
 * @package  Arcanesoft\Foundation\ViewComposers\System
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class ServerRequirementsComposer
12
{
13
    /* -----------------------------------------------------------------
14
     |  Constants
15
     | -----------------------------------------------------------------
16
     */
17
18
    const VIEW = 'foundation::admin.system.information._includes.server-requirements';
19
20
    /* -----------------------------------------------------------------
21
     |  Main Methods
22
     | -----------------------------------------------------------------
23
     */
24
25
    /**
26
     * Compose the view.
27
     *
28
     * @param  \Illuminate\View\View  $view
29
     */
30
    public function compose(View $view)
31
    {
32
        $requirements['server']['ssl']     = $this->checkSslInstalled();
0 ignored issues
show
Comprehensibility Best Practice introduced by
$requirements was never initialized. Although not strictly required by PHP, it is generally a good practice to add $requirements = array(); before regardless.
Loading history...
33
        $requirements['server']['modules'] = $this->getServerModules([
34
            'mod_rewrite',
35
        ]);
36
37
        $view->with('requirements', $requirements);
38
    }
39
40
    /* -----------------------------------------------------------------
41
     |  Other Methods
42
     | -----------------------------------------------------------------
43
     */
44
45
    /**
46
     * Check if SSL is installed.
47
     *
48
     * @return bool
49
     */
50
    private function checkSslInstalled()
51
    {
52
        return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? true : false;
53
    }
54
55
    /**
56
     * Check the APACHE requirements.
57
     *
58
     * @param  array  $requirements
59
     *
60
     * @return \Illuminate\Support\Collection
61
     */
62
    private function getServerModules(array $requirements)
63
    {
64
        if ( ! function_exists('apache_get_modules')) {
65
            return collect([]);
66
        }
67
68
        $modules      = apache_get_modules();
69
        $requirements = array_combine($requirements, $requirements);
70
71
        return collect($requirements)->transform(function ($requirement) use ($modules) {
72
            return in_array($requirement, $modules);
73
        });
74
    }
75
}
76