Issues (16)

src/Loader/GlobFileLoader.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of DivineNii opensource projects.
7
 *
8
 * PHP version 7.4 and above required
9
 *
10
 * @author    Divine Niiquaye Ibok <[email protected]>
11
 * @copyright 2021 DivineNii (https://divinenii.com/)
12
 * @license   https://opensource.org/licenses/BSD-3-Clause License
13
 *
14
 * For the full copyright and license information, please view the LICENSE
15
 * file that was distributed with this source code.
16
 */
17
18
namespace Rade\DI\Loader;
19
20
use Rade\DI\ContainerBuilder;
21
22
/**
23
 * GlobFileLoader loads files from a glob pattern.
24
 *
25
 * @author Divine Niiquaye Ibok <[email protected]>
26
 */
27
class GlobFileLoader extends FileLoader
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32 1
    public function load($resource, string $type = null): void
33
    {
34 1
        foreach ($this->glob($resource, false, $globResource) as $path => $info) {
35 1
            $this->import($path);
36
        }
37
38 1
        if ($this->container instanceof ContainerBuilder) {
39 1
            $this->container->addResource($globResource);
0 ignored issues
show
The method addResource() does not exist on Rade\DI\AbstractContainer. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
            $this->container->/** @scrutinizer ignore-call */ 
40
                              addResource($globResource);
Loading history...
40
        }
41 1
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 2
    public function supports($resource, string $type = null)
47
    {
48 2
        return 'glob' === $type;
49
    }
50
}
51