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

SchemaManagerFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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