Completed
Push — master ( 215d99...92be6e )
by Tristan
10:33
created

SchemaManagerFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 33
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createFromFile() 0 14 3
1
<?php
2
3
namespace Nicofuma\SwaggerBundle\Swagger;
4
5
use FR3D\SwaggerAssertions\SchemaManager;
6
use Symfony\Component\HttpKernel\KernelInterface;
7
8
class SchemaManagerFactory
9
{
10
    /** @var KernelInterface */
11
    private $kernel;
12
13 4
    public function __construct(KernelInterface $kernel)
14
    {
15 4
        $this->kernel = $kernel;
16 4
    }
17
18
    /**
19
     * Instantiates a new SchemaManager from a given file.
20
     * The file can be an absolute path, a resource located in app/Resources or a resource located in a bundle.
21
     *
22
     * @param string $file
23
     *
24
     * @return SchemaManager
25
     */
26 4
    public function createFromFile($file)
27
    {
28 4
        if (is_file($file)) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies 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 if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

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

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
29
            // Do nothing
30 4
        } elseif (is_file($this->kernel->getRootDir().'/Resources/'.$file)) {
31 1
            $file = $this->kernel->getRootDir().'/Resources/'.$file;
32 1
        } else {
33 2
            $file = $this->kernel->locateResource($file);
34
        }
35
36 3
        $uri = 'file://'.$file;
37
38 3
        return SchemaManager::fromUri($uri);
39
    }
40
}
41