• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eliashaeussler / composer-update-check / 15127653356

19 May 2025 08:30PM UTC coverage: 20.538%. First build
15127653356

Pull #130

github

web-flow
[TASK] Update cuyz/valinor to v1.16.1

| datasource | package      | from   | to     |
| ---------- | ------------ | ------ | ------ |
| packagist  | cuyz/valinor | 1.15.0 | 1.16.1 |
Pull Request #130: [!!!][FEATURE] Modernize plugin

356 of 1832 new or added lines in 57 files covered. (19.43%)

382 of 1860 relevant lines covered (20.54%)

1.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/DependencyInjection/ContainerFactory.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/composer-update-check".
7
 *
8
 * Copyright (C) 2020-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\ComposerUpdateCheck\DependencyInjection;
25

26
use EliasHaeussler\ComposerUpdateCheck\Exception;
27
use Symfony\Component\Config;
28
use Symfony\Component\DependencyInjection;
29
use Symfony\Component\Filesystem;
30

31
use function array_unique;
32
use function array_values;
33
use function dirname;
34

35
/**
36
 * ContainerFactory.
37
 *
38
 * @author Elias Häußler <elias@haeussler.dev>
39
 * @license GPL-3.0-or-later
40
 *
41
 * @internal
42
 */
43
final class ContainerFactory
44
{
45
    /**
46
     * @var list<string>
47
     */
48
    private readonly array $configs;
49

50
    /**
51
     * @param list<string> $configs
52
     */
NEW
53
    public function __construct(array $configs = [])
×
54
    {
NEW
55
        $defaultConfigurationFiles = $this->getDefaultConfigurationFiles();
×
56

NEW
57
        $this->configs = array_values(
×
NEW
58
            array_unique([
×
NEW
59
                ...$defaultConfigurationFiles,
×
NEW
60
                ...$configs,
×
NEW
61
            ]),
×
NEW
62
        );
×
63
    }
64

65
    /**
66
     * @throws Exception\ConfigFileIsNotSupported
67
     */
NEW
68
    public function make(bool $debug = false): DependencyInjection\ContainerInterface
×
69
    {
NEW
70
        $container = new DependencyInjection\ContainerBuilder();
×
71

NEW
72
        foreach ($this->configs as $config) {
×
NEW
73
            $loader = $this->createLoader($config, $container);
×
NEW
74
            $loader->load($config);
×
75
        }
76

NEW
77
        if ($debug) {
×
NEW
78
            $containerXmlFilename = $this->buildContainerXmlFilename($container);
×
NEW
79
            $container->addCompilerPass(new CompilerPass\ContainerBuilderDebugDumpPass($containerXmlFilename));
×
80
        }
81

NEW
82
        $container->compile(true);
×
83

NEW
84
        return $container;
×
85
    }
86

87
    /**
88
     * @throws Exception\ConfigFileIsNotSupported
89
     */
NEW
90
    private function createLoader(
×
91
        string $filename,
92
        DependencyInjection\ContainerBuilder $container,
93
    ): Config\Loader\LoaderInterface {
NEW
94
        $locator = new Config\FileLocator($filename);
×
95

NEW
96
        return match (Filesystem\Path::getExtension($filename, true)) {
×
NEW
97
            'php' => new DependencyInjection\Loader\PhpFileLoader($container, $locator),
×
NEW
98
            'yaml', 'yml' => new DependencyInjection\Loader\YamlFileLoader($container, $locator),
×
NEW
99
            'xml' => new DependencyInjection\Loader\XmlFileLoader($container, $locator),
×
NEW
100
            default => throw new Exception\ConfigFileIsNotSupported($filename),
×
NEW
101
        };
×
102
    }
103

104
    /**
105
     * @return list<non-empty-string>
106
     */
NEW
107
    private function getDefaultConfigurationFiles(): array
×
108
    {
NEW
109
        $configDir = dirname(__DIR__, 2).'/config';
×
110

NEW
111
        return [
×
NEW
112
            $configDir.'/services.yaml',
×
NEW
113
        ];
×
114
    }
115

NEW
116
    private function buildContainerXmlFilename(DependencyInjection\ContainerBuilder $container): string
×
117
    {
NEW
118
        $filename = dirname(__DIR__, 2).'/.build/cache/container.xml';
×
119

NEW
120
        $container->setParameter('debug.container_xml_filename', $filename);
×
121

NEW
122
        return $filename;
×
123
    }
124
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc