Completed
Push — master ( 416cb1...222de5 )
by Anton
03:44
created

Users::processItem()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4286
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
3
namespace Modules\Entitizer\Listview {
4
5
	use Modules\Auth, Modules\Entitizer, Utils\Lister, Template;
6
7
	class Users extends Entitizer\Utils\Listview {
8
9
		use Entitizer\Common\User;
10
11
		# Listview configuration
12
13
		protected static $lister = 'Modules\Entitizer\Lister\Users';
14
15
		protected static $link = '/admin/system/users';
16
17
		protected static $naming = 'name';
18
19
		protected static $display = CONFIG_ADMIN_USERS_DISPLAY;
20
21
		protected static $view_main = 'Blocks\Entitizer\Users\Listview\Main';
22
23
		protected static $view_item = 'Blocks\Entitizer\Users\Listview\Item';
24
25
		protected static $view_ajax_main = '';
26
27
		protected static $view_ajax_item = '';
28
29
		# Add additional data for specific entity
30
31
		protected function processEntity() {}
32
33
		# Add item additional data
34
35
		protected function processItem(Template\Asset\Block $view, Entitizer\Entity\User $user) {
36
37
			$view->rank = Lister\Rank::get($user->rank);
0 ignored issues
show
Documentation introduced by
The property rank does not exist on object<Template\Asset\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...
Documentation introduced by
The property rank does not exist on object<Modules\Entitizer\Entity\User>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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
			if ($user->id === Auth::user()->id) $view->block('remove')->class = 'disabled';
0 ignored issues
show
Documentation introduced by
The property $id is declared protected in Modules\Entitizer\Utils\Entity. 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...
40
		}
41
	}
42
}
43