ErrorPresenter::renderDefault()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 8
cp 0
rs 9.8333
c 0
b 0
f 0
cc 3
nc 4
nop 1
crap 12
1
<?php
2
3
namespace UniMan\Presenters;
4
5
use Nette\Application\BadRequestException;
6
7
class ErrorPresenter extends AbstractBasePresenter
8
{
9
    public function renderDefault($exception)
10
    {
11
        if ($exception instanceof BadRequestException) {
12
            $this->setView('4xx');
13
        } else {
14
            $this->setView('500');
15
        }
16
17
        if ($this->isAjax()) {
18
            $this->payload->error = true;
0 ignored issues
show
Documentation introduced by
The property $payload is declared private in Nette\Application\UI\Presenter. 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...
19
            $this->sendPayload();
20
        }
21
    }
22
}
23