Completed
Pull Request — master (#14)
by Tomáš
03:35
created

ProxySourceTaxonomyIndexGenerator   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 4
dl 0
loc 101
ccs 0
cts 56
cp 0
rs 10
c 0
b 0
f 0
1
<?php
2
3
$permalink = $source->data()->get('permalink') ?: $source->relativePathname();
4
$basename = basename($permalink);
5
6
$permalink = dirname($permalink);
7
8
$indexType = null;
9
10
if (preg_match('/^(.+?)\.(.+)$/', $basename, $matches)) {
11
    $urlTaxon = $this->permalinkStrategyCollection->process($taxon);
12
    $indexType = $matches[2];
13
    $suffix = in_array($indexType, ['xml', 'rss', 'json']) ? '.'.$indexType : '/';
14
    $permalink = $permalink.'/'.$urlTaxon.$suffix;
15
} else {
0 ignored issues
show
Unused Code introduced by
This else statement is empty and can be removed.

This check looks for the else branches of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These else branches can be removed.

if (rand(1, 6) > 3) {
print "Check failed";
} else {
    //print "Check succeeded";
}

could be turned into

if (rand(1, 6) > 3) {
    print "Check failed";
}

This is much more concise to read.

Loading history...
16
    // not sure what case this is?
17
}
18
19
if (0 === strpos($permalink, './')) {
20
    $permalink = substr($permalink, 2);
21
}
22
23
if (0 !== strpos($permalink, '/')) {
24
    $permalink = '/'.$permalink;
25
}
26
27
if ($permalink) {
28
    // not sure if this is ever going to happen?
29
    $generatedSource->data()->set('permalink', $permalink);
30
}
31
32
33