Completed
Pull Request — master (#28)
by Robbie
12:24
created

ComposerUpdateReportExtension::updateColumns()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 17
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 9
nc 1
nop 1
1
<?php
2
3
namespace BringYourOwnIdeas\UpdateChecker\Extensions;
4
5
use Extension;
6
7
class ComposerUpdateReportExtension extends Extension
8
{
9
    /**
10
     * Adds the available and latest versions to the site summary report
11
     *
12
     * @param array $columns
13
     */
14
    public function updateColumns(&$columns)
15
    {
16
        $columns['AvailableVersion'] = [
17
            'title' => _t(__CLASS__ . '.AVAILABLE', 'Available'),
18
            // If the available version update is the same as the currently installed version, don't show it
19
            'formatting' => function ($value, $item) {
20
                if ($value === $item->Version) {
21
                    return '';
22
                }
23
                return $value;
24
            },
25
        ];
26
27
        $columns['LatestVersion'] = [
28
            'title' => _t(__CLASS__ . '.LATEST', 'Latest')
29
        ];
30
    }
31
}
32