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.
Completed
Push — master ( be0626...df8c18 )
by Théo
33:01
created

KernelFileResolver::resolveFile()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 11
nc 6
nop 1
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 Nelmio\Alice\NotClonableTrait;
18
use Symfony\Component\HttpKernel\KernelInterface;
19
20
/**
21
 * @author Théo FIDRY <[email protected]>
22
 */
23
final class KernelFileResolver implements FileResolverInterface
24
{
25
    use NotClonableTrait;
26
27
    /**
28
     * @var KernelInterface
29
     */
30
    private $kernel;
31
32
    public function __construct(KernelInterface $kernel)
33
    {
34
        $this->kernel = $kernel;
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function resolve(array $filePaths): array
41
    {
42
        $resolvedFixtures = [];
43
        foreach ($filePaths as $file) {
44
            $resolvedFixtures[$this->resolveFile($file)] = true;
45
        }
46
47
        return array_keys($resolvedFixtures);
48
    }
49
50
    public function resolveFile(string $file): string
51
    {
52
        $realFile = ('@' === $file[0])
53
            ? $this->kernel->locateResource($file, null, true)
54
            : $file
55
        ;
56
57
        $realFile = realpath($realFile);
58
        if (false === $realFile || false === file_exists($realFile)) {
59
            throw new \InvalidArgumentException(sprintf('The file "%s" was not found.', $file));
60
        }
61
        if (false === is_file($realFile)) {
62
            throw new \InvalidArgumentException(
63
                sprintf('Expected "%s" to be a fixture file, got a directory instead.', $file)
64
            );
65
        }
66
67
        return $realFile;
68
    }
69
}
70