Passed
Push — master ( 2f56fd...c7e98d )
by Anton
05:11 queued 01:55
created

Information::processDebugMode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace Modules\Informer\Handler {
4
5
	use Frames, Modules\Informer, Utils\View, Language, Template;
6
7
	class Information extends Frames\Admin\Area\Authorized {
8
9
		protected $title = 'TITLE_SYSTEM_INFORMATION';
10
11
		# Process debug mode block
12
13
		private function processDebugMode(Template\Block $debug_mode) {
14
15
			if (DEBUG_MODE) {
16
17
				$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...
18
19
				$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...
20
21
			} else {
22
23
				$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...
24
25
				$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...
26
			}
27
		}
28
29
		# Get contents
30
31
		private function getContents() {
32
33
			$contents = View::get('Blocks/Informer/Information');
34
35
			# Set server entries
36
37
			$contents->os_version           = Informer::osVersion();
38
39
			$contents->php_version          = phpversion();
40
41
			$contents->mysql_version        = Informer::mysqlVersion();
42
43
			# Set system entries
44
45
			$contents->system_version       = CADMIUM_VERSION;
46
47
			# Set external entries
48
49
			$contents->jquery_version       = JQUERY_VERSION;
50
51
			$contents->semantic_ui_version  = SEMANTIC_UI_VERSION;
52
53
			$contents->ckeditor_version     = CKEDITOR_VERSION;
54
55
			# Set debug mode
56
57
			$this->processDebugMode($contents->getBlock('debug_mode'));
58
59
			# ------------------------
60
61
			return $contents;
62
		}
63
64
		# Handle request
65
66
		protected function handle() {
67
68
			return $this->getContents();
69
		}
70
	}
71
}
72