Completed
Push — master ( 55accb...6b95b9 )
by
unknown
17:55
created

ComposerUpdateExtension::requireDefaultRecords()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace BringYourOwnIdeas\UpdateChecker\Extensions;
4
5
use DataExtension;
6
7
/**
8
 * Describes any available updates to an installed Composer package
9
 *
10
 * Originally from https://github.com/XploreNet/silverstripe-composerupdates
11
 */
12
class ComposerUpdateExtension extends DataExtension
13
{
14
    private static $db = [
0 ignored issues
show
Unused Code introduced by
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
15
        'VersionHash' => 'Varchar',
16
        'VersionConstraint' => 'Varchar(50)',
17
        'AvailableVersion' => 'Varchar(50)',
18
        'AvailableHash' => 'Varchar(50)',
19
        'LatestVersion' => 'Varchar(50)',
20
        'LatestHash' => 'Varchar(50)',
21
    ];
22
23
    private static $summary_fields = [
0 ignored issues
show
Unused Code introduced by
The property $summary_fields is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
24
        'AvailableVersion' => 'Available',
25
        'LatestVersion' => 'Latest',
26
    ];
27
28
    /**
29
     * If the available version is the same as the current version then return nothing, otherwise show the latest
30
     * available version
31
     *
32
     * @return string
33
     */
34
    public function getAvailableVersion()
35
    {
36
        if ($this->owner->getField('Version') === $this->owner->getField('AvailableVersion')) {
37
            return '';
38
        }
39
        return $this->owner->getField('AvailableVersion');
40
    }
41
}
42