Passed
Push — master ( 26efa5...f69765 )
by Alex
03:20
created

TNamespaceNameTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 0
cbo 1
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A isTNamespaceNameValid() 0 16 3
1
<?php
2
3
namespace AlgoWeb\ODataMetadata\MetadataV4\edm\IsOKTraits;
4
5
use AlgoWeb\ODataMetadata\xsdRestrictions;
6
7
trait TNamespaceNameTrait
8
{
9
    use xsdRestrictions;
10
11
    protected function isTNamespaceNameValid($TNamespaceName)
12
    {
13
        if (!$this->isNCName($TNamespaceName)) {
14
            $msg = "Term namespace must be a valid NCName";
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
15
            return false;
16
        }
17
        //<!-- one or more SimpleIdentifiers separated by dots -->
18
        if (!$this->matchesRegexPattern(
19
            "[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]{0,}(\.[\p{L}\p{Nl}_][\p{L}\p{Nl}\p{Nd}\p{Mn}\p{Mc}\p{Pc}\p{Cf}]{0,}){0,}",
20
            $TNamespaceName
21
        )) {
22
            $msg = "The term namespace does not match the regex in the xsd.";
0 ignored issues
show
Unused Code introduced by
$msg is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
23
            return false;
24
        }
25
        return true;
26
    }
27
}
28