ComposerUpdateExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAvailableVersion() 0 6 2
1
<?php
2
3
namespace BringYourOwnIdeas\UpdateChecker\Extensions;
4
5
use SilverStripe\ORM\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
introduced by Robbie Averill
The private property $db is not used, and could 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
introduced by Robbie Averill
The private property $summary_fields is not used, and could 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