StaffDirectoryController::GroupedList()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
ccs 4
cts 4
cp 1
crap 1
1
<?php
2
3
namespace Dynamic\Staff\Pages;
4
5
use PageController;
6
use SilverStripe\Control\HTTPRequest;
7
use SilverStripe\ORM\GroupedList;
8
use SilverStripe\ORM\PaginatedList;
9
10
/**
11
 * Class StaffDirectoryController
12
 * @package Dynamic\Staff\Pages
13
 */
14
class StaffDirectoryController extends PageController
15
{
16
    /**
17
     * @return int
18
     */
19 2
    public function getPageSize()
20
    {
21 2
        if ($object = $this->config()->page_size) {
22 1
            return (int)$object;
23
        }
24
25 2
        return 10;
26
    }
27
28
    /**
29
     * @param HTTPRequest|null $request
30
     *
31
     * @return PaginatedList
32
     */
33 1
    public function PaginatedList(HTTPRequest $request = null)
34
    {
35 1
        if ($request === null) {
36 1
            $request = $this->request;
37
        }
38 1
        $start = ($request->getVar('start')) ? (int)$request->getVar('start') : 0;
39
40 1
        $records = PaginatedList::create($this->getStaffMembers(), $this->request);
0 ignored issues
show
Bug introduced by
The method getStaffMembers() does not exist on Dynamic\Staff\Pages\StaffDirectoryController. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        $records = PaginatedList::create($this->/** @scrutinizer ignore-call */ getStaffMembers(), $this->request);
Loading history...
41 1
        $records->setPageStart($start);
42 1
        $records->setPageLength($this->getPageSize());
43
44
        // allow $records to be updated via extension
45 1
        $this->extend('updatePaginatedList', $records);
46
47 1
        return $records;
48
    }
49
50
    /**
51
     * @return GroupedList
52
     */
53 1
    public function GroupedList()
54
    {
55 1
        $records = GroupedList::create($this->getStaffMembers());
56
57
        // allow $records to be updated via extension
58 1
        $this->owner->extend('updateGroupedList', $records);
0 ignored issues
show
Bug introduced by
The method extend() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

58
        $this->owner->/** @scrutinizer ignore-call */ 
59
                      extend('updateGroupedList', $records);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug Best Practice introduced by
The property owner does not exist on Dynamic\Staff\Pages\StaffDirectoryController. Since you implemented __get, consider adding a @property annotation.
Loading history...
59
60 1
        return $records;
61
    }
62
}
63