Passed
Push — master ( 1b2674...3c6afc )
by Robbie
01:36
created

SitewideContentReview::updateColumns()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 26
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 13
nc 2
nop 2
dl 0
loc 26
rs 8.8571
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\SiteWideContentReport\Model;
4
5
use SilverStripe\Core\Extension;
6
7
/**
8
 * Provides contentreview integration for sitewide content report.
9
 *
10
 * Requires https://github.com/silverstripe/silverstripe-contentreview
11
 * Class SitewideContentReview
12
 * @package SilverStripe\SiteWideContentReport\Model
13
 */
14
class SitewideContentReview extends Extension
15
{
16
    /**
17
     * Update columns to include subsite details.
18
     *
19
     * @param string $itemType (i.e 'Pages' or 'Files')
20
     * @param array $columns Columns
21
     * @return mixed
22
     */
23
    public function updateColumns($itemType, &$columns)
24
    {
25
        if ($itemType !== 'Pages') {
26
            return;
27
        }
28
29
        // {@see SiteTreeContentReview::getOwnerNames()}
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
30
        $columns['OwnerNames'] = [
31
            'printonly' => true, // Hide on page report
32
            'title' => _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.Reviewer', 'Reviewer'),
33
        ];
34
35
        // {@see SiteTreeContentView::getReviewDate()}
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
36
        $columns['ReviewDate'] = [
37
            'printonly' => true, // Hide on page report
38
            'title' => _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.ReviewDate', 'Review Date'),
39
            'formatting' => function ($value, $record) {
40
                if ($val = $record->getReviewDate()) {
41
                    return $val->Nice();
42
                }
43
44
                return null;
45
            },
46
        ];
47
48
        return;
49
    }
50
}
51