Passed
Push — master ( c7e98d...e0d6a2 )
by Anton
04:56 queued 01:50
created

Information::getBooleanValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
1
<?php
2
3
namespace Modules\Informer\Handler {
4
5
	use Frames, Modules\Informer, Utils\Validate, Utils\View, Language, Template;
6
7
	class Information extends Frames\Admin\Area\Authorized {
8
9
		protected $title = 'TITLE_SYSTEM_INFORMATION';
10
11
		# Get boolean value for php configuration
12
13
		private function getBooleanValue(string $value) {
14
15
			return (Validate::boolean($value) ? 'On' : 'Off');
16
		}
17
18
		# Process debug mode block
19
20
		private function processDebugMode(Template\Block $debug_mode) {
21
22
			if (DEBUG_MODE) {
23
24
				$debug_mode->class = 'red';
0 ignored issues
show
Documentation introduced by
The property class does not exist on object<Template\Block>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
25
26
				$debug_mode->text = Language::get('INFORMATION_VALUE_DEBUG_MODE_ON');
0 ignored issues
show
Documentation introduced by
The property text does not exist on object<Template\Block>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
27
28
			} else {
29
30
				$debug_mode->class = '';
0 ignored issues
show
Documentation introduced by
The property class does not exist on object<Template\Block>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
31
32
				$debug_mode->text = Language::get('INFORMATION_VALUE_DEBUG_MODE_OFF');
0 ignored issues
show
Documentation introduced by
The property text does not exist on object<Template\Block>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
33
			}
34
		}
35
36
		# Get contents
37
38
		private function getContents() {
39
40
			$contents = View::get('Blocks/Informer/Information');
41
42
			# Set server entries
43
44
			$contents->os_version           = Informer::osVersion();
45
46
			$contents->php_version          = phpversion();
47
48
			$contents->mysql_version        = Informer::mysqlVersion();
49
50
			# Set system entries
51
52
			$contents->system_version       = CADMIUM_VERSION;
53
54
			# Set external entries
55
56
			$contents->jquery_version       = JQUERY_VERSION;
57
58
			$contents->semantic_ui_version  = SEMANTIC_UI_VERSION;
59
60
			$contents->ckeditor_version     = CKEDITOR_VERSION;
61
62
			# Set php entries
63
64
			$contents->php_display_errors           = $this->getBooleanValue(ini_get('display_errors'));
65
66
			$contents->php_display_startup_errors   = $this->getBooleanValue(ini_get('display_startup_errors'));
67
68
			$contents->php_file_uploads             = $this->getBooleanValue(ini_get('file_uploads'));
69
70
			$contents->php_upload_max_filesize      = ini_get('upload_max_filesize');
71
72
			$contents->php_post_max_size            = ini_get('post_max_size');
73
74
			# Set debug mode
75
76
			$this->processDebugMode($contents->getBlock('debug_mode'));
77
78
			# ------------------------
79
80
			return $contents;
81
		}
82
83
		# Handle request
84
85
		protected function handle() {
86
87
			return $this->getContents();
88
		}
89
	}
90
}
91