LegacyDetector::detect()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 8
nc 5
nop 1
crap 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