SettingsPresenter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 2
cbo 2
dl 0
loc 38
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A startup() 0 4 1
A beforeRender() 0 4 1
A actionDefault() 0 3 1
A renderDefault() 0 6 1
A createComponentSettingsForm() 0 14 1
1
<?php
2
3
/**
4
 * This file is part of the Investform module for webcms2.
5
 * Copyright (c) @see LICENSE
6
 */
7
8
namespace AdminModule\InvestformModule;
9
10
/**
11
 * Description of
12
 * @author Tomáš Voslař <tomas.voslar at webcook.cz>
13
 */
14
class SettingsPresenter extends BasePresenter
15
{	
16
    protected function startup()
17
    {
18
		parent::startup();
19
    }
20
21
    protected function beforeRender()
22
    {
23
		parent::beforeRender();	
24
    }
25
	
26
    public function actionDefault($idPage)
27
    {
28
    }
29
	
30
    public function createComponentSettingsForm()
31
    {
32
		$settings = array();
33
34
        $settings[] = $this->settings->get('Form Subject', 'InvestformModule', 'text');
35
        $settings[] = $this->settings->get('Form Email body', 'InvestformModule', 'textarea');
36
        $settings[] = $this->settings->get('Contract Subject', 'InvestformModule', 'text');
37
        $settings[] = $this->settings->get('Contract Email body', 'InvestformModule', 'textarea');
38
        $settings[] = $this->settings->get('Notification subject', 'InvestformModule', 'text');
39
        $settings[] = $this->settings->get('Notification body', 'InvestformModule', 'textarea');
40
        $settings[] = $this->settings->get('Businessman password', 'InvestformModule', 'text');
41
42
		return $this->createSettingsForm($settings);
43
    }
44
	
45
    public function renderDefault($idPage)
46
    {
47
		$this->reloadContent();
48
49
		$this->template->idPage = $idPage;
0 ignored issues
show
Documentation introduced by
The property $template is declared private in Nette\Application\UI\Control. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

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...
Bug introduced by
Accessing idPage on the interface Nette\Templating\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
50
    }
51
}