Sugarcrm::getBuildVersion()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 10
loc 10
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace Sugarcrm\UpgradeSpec\Helper;
4
5
use Sugarcrm\UpgradeSpec\Version\Version;
6
7
class Sugarcrm
8
{
9
    /**
10
     * Extracts version number from sugarcrm build files.
11
     *
12
     * @param $path
13
     *
14
     * @return Version
15
     */
16 View Code Duplication
    public function getBuildVersion($path)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18
        if (!defined('sugarEntry')) {
19
            define('sugarEntry', true);
0 ignored issues
show
Coding Style introduced by
This constant is not in uppercase (expected 'SUGARENTRY').
Loading history...
20
        }
21
22
        require realpath($path) . '/sugar_version.php';
23
24
        return new Version($sugar_version);
0 ignored issues
show
Bug introduced by
The variable $sugar_version does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
25
    }
26
27
    /**
28
     * Extracts flav from sugarcrm build files.
29
     *
30
     * @param $path
31
     *
32
     * @return string
33
     */
34 View Code Duplication
    public function getBuildFlav($path)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
    {
36
        if (!defined('sugarEntry')) {
37
            define('sugarEntry', true);
0 ignored issues
show
Coding Style introduced by
This constant is not in uppercase (expected 'SUGARENTRY').
Loading history...
38
        }
39
40
        require realpath($path) . '/sugar_version.php';
41
42
        return $sugar_flavor;
0 ignored issues
show
Bug introduced by
The variable $sugar_flavor does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
43
    }
44
45
    /**
46
     * Verifies if given path represents a valid SugarCRM build.
47
     *
48
     * @param $path
49
     *
50
     * @return bool
51
     */
52
    public function isSugarcrmBuild($path)
53
    {
54
        return $path && file_exists(realpath($path) . '/sugar_version.php');
55
    }
56
}
57