Completed
Push — 1.0 ( 2476f6...9c5da5 )
by David
10s
created

TestServiceProvider::getFactories()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace TheCodingMachine\Interop\ServiceProviderBridgeBundle\Tests\Fixtures;
3
4
use Interop\Container\ContainerInterface;
5
use Interop\Container\ServiceProviderInterface;
6
7
function myFunctionFactory()
8
{
9
    return 42;
10
}
11
12
class TestServiceProvider implements ServiceProviderInterface
13
{
14
    public function getFactories()
15
    {
16
        return [
17
            'serviceA' => function (ContainerInterface $container) {
18
                $instance = new \stdClass();
19
                $instance->serviceB = $container->get('serviceB');
20
21
                return $instance;
22
            },
23
            'serviceB' => [ TestServiceProvider::class, 'createServiceB' ],
24
            'function' => 'TheCodingMachine\\Interop\\ServiceProviderBridgeBundle\\Tests\\Fixtures\\myFunctionFactory'
25
        ];
26
    }
27
28
    public static function createServiceB(ContainerInterface $container)
29
    {
30
        $instance = new \stdClass();
31
        // Test getting the database_host parameter.
32
        $instance->parameter = $container->get('database_host');
33
        return $instance;
34
    }
35
36
    public function getExtensions()
37
    {
38
        return [];
39
    }
40
}
41