GroupsController::beforeFilter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace App\Controller;
3
4
use Cake\Core\Configure;
5
use Cake\Event\Event;
6
7
class GroupsController extends AppController
8
{
9
10
    /**
11
     * BeforeFilter handle.
12
     *
13
     * @param Event $event The beforeFilter event that was fired.
14
     *
15
     * @return void
16
     */
17
    public function beforeFilter(Event $event)
18
    {
19
        parent::beforeFilter($event);
20
21
        $this->Auth->allow(['view']);
22
    }
23
24
    /**
25
     * Display members by a group.
26
     *
27
     * @return void
28
     */
29
    public function view()
30
    {
31
        $this->paginate = [
32
            'maxLimit' => Configure::read('Group.user_per_page')
33
        ];
34
35
        $this->Users = $this->loadModel('Users');
0 ignored issues
show
Documentation introduced by
The property Users does not exist on object<App\Controller\GroupsController>. 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
        $users = $this->Users
0 ignored issues
show
Documentation introduced by
The property Users does not exist on object<App\Controller\GroupsController>. 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
            ->find()
39
            ->contain([
40
                'Groups'
41
            ])
42
            ->where([
43
                'Groups.id' => $this->request->id
44
            ]);
45
46
        $users = $this->paginate($users);
47
48
        $this->set(compact('users'));
49
    }
50
}
51