Version   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 50
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInfo() 0 11 3
A getCheck() 0 7 1
1
<?php
2
/**
3
 * Mage Scan
4
 *
5
 * PHP version 5
6
 *
7
 * @category  MageScan
8
 * @package   MageScan
9
 * @author    Steve Robbins <[email protected]>
10
 * @copyright 2015 Steve Robbins
11
 * @license   http://creativecommons.org/licenses/by/4.0/ CC BY 4.0
12
 * @link      https://github.com/steverobbins/magescan
13
 */
14
15
namespace MageScan\Check;
16
17
/**
18
 * Scan for Magento edition and version
19
 *
20
 * @category  MageScan
21
 * @package   MageScan
22
 * @author    Steve Robbins <[email protected]>
23
 * @copyright 2015 Steve Robbins
24
 * @license   http://creativecommons.org/licenses/by/4.0/ CC BY 4.0
25
 * @link      https://github.com/steverobbins/magescan
26
 */
27
class Version extends AbstractCheck
28
{
29
    const EDITION_ENTERPRISE   = 'Enterprise';
30
    const EDITION_PROFESSIONAL = 'Professional';
31
    const EDITION_COMMUNITY    = 'Community';
32
33
    /**
34
     * Various ways we can sniff out the Magento version
35
     *
36
     * @var string[]
37
     */
38
    protected $versionCheck = [
39
        'FileHash',
40
        'DownloaderComment',
41
        'DocComment',
42
        'VersionController',
43
    ];
44
45
    /**
46
     * Guess Magento edition and version
47
     *
48
     * @return array
49
     */
50
    public function getInfo()
51
    {
52
        foreach ($this->versionCheck as $name) {
53
            $check = $this->getCheck($name);
54
            $result = $check->getInfo();
55
            if ($result !== false) {
56
                return $result;
57
            }
58
        }
59
        return [false, false];
60
    }
61
62
    /**
63
     * Get check object
64
     *
65
     * @param string $name
66
     *
67
     * @return AbstractCheck
68
     */
69
    protected function getCheck($name)
70
    {
71
        $class = '\\MageScan\\Check\\Version\\' . $name;
72
        $check = new $class;
73
        $check->setRequest($this->getRequest());
74
        return $check;
75
    }
76
}
77