LegacyDetector   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 20
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B detect() 0 16 5
1
<?php
2
3
namespace Buttress\Concrete\Locator\Detector;
4
5
use Buttress\Concrete\Locator\Site;
6
7
final class LegacyDetector implements Detector
8
{
9
10 6
    public function detect($path)
11
    {
12 6
        if (file_exists($path . '/concrete/config/version.php')) {
13 6
            if (!defined('C5_EXECUTE')) {
14 3
                define('C5_EXECUTE', true);
15 2
            }
16
17 6
            @include $path . '/concrete/config/version.php';
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
18
19 6
            if (isset($APP_VERSION) && $APP_VERSION) {
0 ignored issues
show
Bug introduced by
The variable $APP_VERSION seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
20 3
                return Site::create($path, $APP_VERSION);
21
            }
22 2
        }
23
24 3
        return null;
25
    }
26
}
27