Passed
Push — master ( a357e7...195a07 )
by Anton
04:22 queued 01:11
created

User   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A processEntity() 0 9 2
1
<?php
2
3
namespace Modules\Entitizer\Handler\Edit {
4
5
	use Modules\Entitizer, Template, Date;
6
7
	class User extends Entitizer\Utils\Handler {
8
9
		use Entitizer\Common\User;
10
11
		protected $title = 'TITLE_SYSTEM_USERS_EDIT';
12
13
		# Handler configuration
14
15
		protected static $controller = 'Modules\Entitizer\Controller\User';
16
17
		protected static $link = '/admin/system/users';
18
19
		protected static $naming = 'name', $naming_new = 'USERS_ITEM_NEW';
20
21
		protected static $form_class = 'Modules\Entitizer\Form\User';
22
23
		protected static $message_success_save = 'USER_SUCCESS_SAVE';
24
25
		protected static $message_error_remove = 'USER_ERROR_REMOVE';
26
27
		protected static $view = 'Blocks/Entitizer/Users/Main';
28
29
		# Add additional data for specific entity
30
31
		protected function processEntity(Template\Block $contents) {
32
33
			if ($this->create) $contents->getBlock('info')->disable(); else {
34
35
				$contents->getBlock('info')->time_registered = Date::get(DATE_FORMAT_DATETIME, $this->entity->time_registered);
0 ignored issues
show
Documentation introduced by
The property time_registered 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...
36
37
				$contents->getBlock('info')->time_logged = Date::get(DATE_FORMAT_DATETIME, $this->entity->time_logged);
0 ignored issues
show
Documentation introduced by
The property time_logged 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...
38
			}
39
		}
40
	}
41
}
42