Passed
Push — develop ( 2a62bc...f4bbde )
by Andrew
06:00 queued 11s
created

Version   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 13
c 1
b 0
f 0
dl 0
loc 34
ccs 0
cts 17
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getLeagueCsvVersion() 0 19 5
1
<?php
2
/**
3
 * Retour plugin for Craft CMS 3.x
4
 *
5
 * Retour allows you to intelligently redirect legacy URLs, so that you don't
6
 * lose SEO value when rebuilding & restructuring a website
7
 *
8
 * @link      https://nystudio107.com/
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
9
 * @copyright Copyright (c) 2021 nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
10
 */
0 ignored issues
show
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
11
12
namespace nystudio107\retour\helpers;
13
14
use \Composer\InstalledVersions;
15
use \Composer\Semver\Semver;
16
17
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
18
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
19
 * @package   Retour
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
20
 * @since     3.1.48
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
Coding Style introduced by
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
21
 */
0 ignored issues
show
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
Coding Style introduced by
Missing @category tag in class comment
Loading history...
22
class Version
23
{
24
    // Constants
25
    // =========================================================================
26
27
    const LEAGUE_CSV_PACKAGE = 'league/csv';
28
29
    // Public Static Methods
30
    // =========================================================================
31
32
    /**
33
     * Return the API version for `league/csv` package
34
     *
35
     * @return int API version (or 0 for not installed)
36
     */
37
    public static function getLeagueCsvVersion(): int
38
    {
39
        $version = 0;
40
        $installedVersion = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $installedVersion is dead and can be removed.
Loading history...
41
        try {
42
            $installedVersion = InstalledVersions::getVersion(self::LEAGUE_CSV_PACKAGE);
43
        } catch (\Throwable $e) {
44
            // That's fine
45
        }
46
        if ($installedVersion) {
47
            if (Semver::satisfies($installedVersion, '^8.0.0')) {
48
                $version = 8;
49
            }
50
            if (Semver::satisfies($installedVersion, '^9.0.0')) {
51
                $version = 9;
52
            }
53
        }
54
55
        return $version;
56
    }
57
}
58