Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ArrayServiceProvider
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFactories
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getExtensions
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * This file is part of php-fast-forward/container.
7 *
8 * This source file is subject to the license bundled
9 * with this source code in the file LICENSE.
10 *
11 * @copyright Copyright (c) 2025-2026 Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
12 * @license   https://opensource.org/licenses/MIT MIT License
13 *
14 * @see       https://github.com/php-fast-forward/container
15 * @see       https://github.com/php-fast-forward
16 * @see       https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\Container\ServiceProvider;
20
21use Interop\Container\ServiceProviderInterface;
22
23/**
24 * Class ArrayServiceProvider.
25 *
26 * A simple implementation of the ServiceProviderInterface that uses plain arrays
27 * to define service factories and extensions. This provider is suitable for static
28 * configuration and testing scenarios where no dynamic resolution is required.
29 *
30 * Factories MUST be defined as an associative array where keys are service IDs and
31 * values are callables. Extensions MUST also follow the same format.
32 */
33  class ArrayServiceProvider implements ServiceProviderInterface
34{
35    /**
36     * Constructs an ArrayServiceProvider with pre-defined factories and extensions.
37     *
38     * @param array<string, callable> $factories the list of service factories
39     * @param array<string, callable> $extensions the list of service extensions
40     * @param array $factories
41     * @param array $extensions
42     */
43    public function __construct(
44        private array $factories = [],
45        private array $extensions = []
46    ) {}
47
48    /**
49     * @return array
50     */
51    public function getFactories(): array
52    {
53        return $this->factories;
54    }
55
56    /**
57     * @return array
58     */
59    public function getExtensions(): array
60    {
61        return $this->extensions;
62    }
63}