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

eliashaeussler / composer-update-check / 11500247089

24 Oct 2024 01:23PM UTC coverage: 20.327%. First build
11500247089

Pull #130

github

renovate[bot]
[TASK] Update php-http/httplug to v2.4.1

| datasource | package          | from  | to    |
| ---------- | ---------------- | ----- | ----- |
| packagist  | php-http/httplug | 2.4.0 | 2.4.1 |
Pull Request #130: [!!!][FEATURE] Modernize plugin

347 of 1809 new or added lines in 56 files covered. (19.18%)

373 of 1835 relevant lines covered (20.33%)

1.09 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-2024 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 dirname;
33

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

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

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

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

NEW
69
        foreach ($this->configs as $config) {
×
NEW
70
            $loader = $this->createLoader($config, $container);
×
NEW
71
            $loader->load($config);
×
72
        }
73

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

NEW
79
        $container->compile(true);
×
80

NEW
81
        return $container;
×
82
    }
83

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

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

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

NEW
108
        return [
×
NEW
109
            $configDir.'/services.yaml',
×
NEW
110
        ];
×
111
    }
112

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

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

NEW
119
        return $filename;
×
120
    }
121
}
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