Test Failed
Push — master ( fb6850...c0ccaa )
by Christopher
04:02
created

MetadataManager::getEdmxXML()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace AlgoWeb\ODataMetadata;
4
5
use AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityTypeType;
6
use AlgoWeb\ODataMetadata\MetadataV3\edmx\Edmx;
7
8
class MetadataManager
9
{
10
    private $V3Edmx = null;
11
12
    private $serializer = null;
13
14
    public function __construct($namespaceName = "Data", $containerName = "DefaultContainer")
15
    {
16
        $this->V3Edmx = new Edmx($namespaceName, $containerName);
17
        if (!$this->V3Edmx->isOK($msg)) {
18
            throw new \Exception($msg);
19
        }
20
        $ymlDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . "MetadataV3" . DIRECTORY_SEPARATOR . "JMSmetadata";
21
        $this->serializer =
22
            \JMS\Serializer\SerializerBuilder::create()
23
                ->addMetadataDir($ymlDir)
24
                ->build();
25
    }
26
27
    public function getEdmx()
28
    {
29
        return $this->V3Edmx;
30
    }
31
32
    public function getEdmxXML()
33
    {
34
        return $this->serializer->serialize($this->edmx, "xml");
0 ignored issues
show
Bug introduced by
The property edmx does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
35
    }
36
37
    public function addEntityType($refClass, $name, $namespace = null)
38
    {
39
        $NewEntity = new TEntityTypeType();
0 ignored issues
show
Unused Code introduced by
$NewEntity 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...
40
        return $this->createResourceType($refClass, $name, $namespace, ResourceTypeKind::ENTITY, null);
0 ignored issues
show
Bug introduced by
The method createResourceType() does not seem to exist on object<AlgoWeb\ODataMetadata\MetadataManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
    }
42
43
    public function addComplexType(\ReflectionClass $refClass, $name, $namespace = null, $baseResourceType = null)
44
    {
45
        return $this->createResourceType($refClass, $name, $namespace, ResourceTypeKind::COMPLEX, $baseResourceType);
0 ignored issues
show
Bug introduced by
The method createResourceType() does not seem to exist on object<AlgoWeb\ODataMetadata\MetadataManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
    }
47
48
49
}