GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

KernelFileResolver   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolve() 0 9 2
B resolveFile() 0 19 5
1
<?php
2
3
/*
4
 * This file is part of the Hautelook\AliceBundle package.
5
 *
6
 * (c) Baldur Rensch <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Hautelook\AliceBundle\Resolver\File;
15
16
use Fidry\AliceDataFixtures\FileResolverInterface;
17
use InvalidArgumentException;
18
use Nelmio\Alice\IsAServiceTrait;
19
use Symfony\Component\HttpKernel\KernelInterface;
20
21
final class KernelFileResolver implements FileResolverInterface
22
{
23
    use IsAServiceTrait;
24
25
    private $kernel;
26
27
    public function __construct(KernelInterface $kernel)
28
    {
29
        $this->kernel = $kernel;
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function resolve(array $filePaths): array
36
    {
37
        $resolvedFixtures = [];
38
        foreach ($filePaths as $file) {
39
            $resolvedFixtures[$this->resolveFile($file)] = true;
40
        }
41
42
        return array_keys($resolvedFixtures);
43
    }
44
45
    public function resolveFile(string $file): string
46
    {
47
        $realFile = ('@' === $file[0])
48
            ? $this->kernel->locateResource($file, null, true)
49
            : $file
50
        ;
51
52
        $realFile = realpath($realFile);
53
        if (false === $realFile || false === file_exists($realFile)) {
54
            throw new InvalidArgumentException(sprintf('The file "%s" was not found.', $file));
55
        }
56
        if (false === is_file($realFile)) {
57
            throw new InvalidArgumentException(
58
                sprintf('Expected "%s" to be a fixture file, got a directory instead.', $file)
59
            );
60
        }
61
62
        return $realFile;
63
    }
64
}
65