AuthorsController::Title()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Handles displaying package authors.
4
 */
5
class AuthorsController extends SiteController
6
{
7
8
    public static $url_handlers = array(
9
        '$AuthorID!' => 'author'
10
    );
11
12
    public static $allowed_actions = array(
13
        'index',
14
        'author'
15
    );
16
17
    public function index()
18
    {
19
        return $this->renderWith(array('Authors', 'Page'));
20
    }
21
22
    public function author($request)
23
    {
24
        $id = $request->param('AuthorID');
25
        $author = AddonAuthor::get()->byID($id);
26
27
        if (!$author) {
28
            $this->httpError(404);
29
        }
30
31
        return new AuthorController($this, $author);
0 ignored issues
show
Documentation introduced by
$author is of type null|object<DataObject>, but the function expects a object<AddonAuthor>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
32
    }
33
34
    public function Title()
35
    {
36
        return 'Authors';
37
    }
38
39
    public function Link()
40
    {
41
        return Controller::join_links(Director::baseURL(), 'authors');
42
    }
43
44
    public function Authors()
45
    {
46
        return AddonAuthor::get();
47
    }
48
}
49