SettingsController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getAction() 0 9 1
1
<?php
2
3
namespace JhFlexiTime\Controller;
4
5
use Zend\Mvc\Controller\AbstractActionController;
6
use Zend\View\Model\JsonModel;
7
use JhFlexiTime\Options\BookingOptions;
8
9
/**
10
 * Class SettingsController
11
 * @package JhFlexiTime\Controller
12
 * @author Aydin Hassan <[email protected]>
13
 */
14
class SettingsController extends AbstractActionController
15
{
16
    /**
17
     * @var BookingOptions
18
     */
19
    protected $bookingOptions;
20
21
    /**
22
     * @param BookingOptions $bookingOptions
23
     */
24
    public function __construct(BookingOptions $bookingOptions)
25
    {
26
        $this->bookingOptions = $bookingOptions;
27
    }
28
29
    /**
30
     * Get Settings
31
     *
32
     * @return JsonModel
33
     */
34
    public function getAction()
35
    {
36
        $user = $this->zfcUserAuthentication()->getIdentity();
0 ignored issues
show
Documentation Bug introduced by
The method zfcUserAuthentication does not exist on object<JhFlexiTime\Controller\SettingsController>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
Unused Code introduced by
$user is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
37
38
        return new JsonModel([
39
            'success'   => true,
40
            'settings'  => $this->bookingOptions,
41
        ]);
42
    }
43
}
44