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

mimmi20 / client-builder / 13464948563

21 Feb 2025 08:46PM UTC coverage: 89.474% (-10.5%) from 100.0%
13464948563

push

github

web-flow
Merge pull request #381 from mimmi20/updates

use laminas/laminas-servicemanager 4.4

0 of 10 new or added lines in 1 file covered. (0.0%)

85 of 95 relevant lines covered (89.47%)

3.25 hits per line

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

50.0
/src/ClientPluginManager.php
1
<?php
2

3
/**
4
 * This file is part of the mimmi20/client-builder package.
5
 *
6
 * Copyright (c) 2022-2025, Thomas Mueller <mimmi20@live.de>
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 Mimmi20\ClientBuilder;
15

16
use Laminas\Http\Client as HttpClient;
17
use Laminas\ServiceManager\AbstractPluginManager;
18
use Laminas\ServiceManager\Exception\InvalidServiceException;
19
use Laminas\ServiceManager\ServiceManager;
20
use Override;
21
use Psr\Container\ContainerExceptionInterface;
22
use Psr\Container\ContainerInterface;
23

24
use function array_merge_recursive;
25
use function get_debug_type;
26
use function sprintf;
27

28
/**
29
 * PluginManager für Berechnungsdaten
30
 *
31
 * @template-extends AbstractPluginManager<HttpClient>
32
 * @phpstan-import-type ServiceManagerConfiguration from ServiceManager
33
 */
34
final class ClientPluginManager extends AbstractPluginManager
35
{
36
    private string $instanceOf = HttpClient::class;
37

38
    /**
39
     * @param array<mixed> $config
40
     * @phpstan-param ServiceManagerConfiguration $config
41
     *
42
     * @throws void
43
     */
44
    public function __construct(ContainerInterface $container, array $config = [])
1✔
45
    {
46
        $config = array_merge_recursive(
1✔
47
            [
1✔
48
                'abstract_factories' => [
1✔
49
                    ClientAbstractFactory::class,
1✔
50
                ],
1✔
51
            ],
1✔
52
            $config,
1✔
53
        );
1✔
54

55
        parent::__construct($container, $config);
1✔
56
    }
57

58
    /**
59
     * Validate an instance
60
     *
61
     * @throws InvalidServiceException if created instance does not respect the constraint on type imposed by the plugin manager
62
     * @throws ContainerExceptionInterface if any other error occurs
63
     *
64
     * @phpstan-assert HttpClient $instance
65
     */
NEW
66
    #[Override]
×
67
    public function validate(mixed $instance): void
68
    {
NEW
69
        if (!$instance instanceof $this->instanceOf) {
×
NEW
70
            throw new InvalidServiceException(
×
NEW
71
                sprintf(
×
NEW
72
                    '%s can only create instances of %s; %s is invalid',
×
NEW
73
                    self::class,
×
NEW
74
                    $this->instanceOf,
×
NEW
75
                    get_debug_type($instance),
×
NEW
76
                ),
×
NEW
77
            );
×
78
        }
79
    }
80
}
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