Version   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 15
c 0
b 0
f 0
dl 0
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getLeagueCsvVersion() 0 20 5
1
<?php
2
/**
3
 * Retour plugin for Craft CMS
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\Semver\Semver;
15
use Craft;
16
use Jean85\PrettyVersions;
17
use Throwable;
18
19
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
20
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
21
 * @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...
22
 * @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...
23
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
24
class Version
25
{
26
    // Constants
27
    // =========================================================================
28
29
    protected const LEAGUE_CSV_PACKAGE = 'league/csv';
30
31
    // Public Static Methods
32
    // =========================================================================
33
34
    /**
35
     * Return the API version for `league/csv` package
36
     *
37
     * @return int API version (or 0 for not installed)
38
     */
39
    public static function getLeagueCsvVersion(): int
40
    {
41
        $version = 0;
42
        $installedVersion = null;
43
        try {
44
            $pv = PrettyVersions::getVersion(self::LEAGUE_CSV_PACKAGE);
45
            $installedVersion = $pv->getPrettyVersion();
46
        } catch (Throwable $e) {
47
            Craft::error($e, __METHOD__);
48
        }
49
        if ($installedVersion) {
50
            if (Semver::satisfies($installedVersion, '^8.0.0')) {
51
                $version = 8;
52
            }
53
            if (Semver::satisfies($installedVersion, '^9.0.0')) {
54
                $version = 9;
55
            }
56
        }
57
58
        return $version;
59
    }
60
}
61