Completed
Push — 1.0 ( 5e8373...d03f73 )
by David
11:40
created

TestServiceProvider.php ➔ myFunctionFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
namespace TheCodingMachine\Interop\ServiceProviderBridgeBundle\Tests\Fixtures;
3
4
use Interop\Container\ContainerInterface;
5
use Interop\Container\ServiceProvider;
6
7
function myFunctionFactory()
8
{
9
    return 42;
10
}
11
12
class TestServiceProvider implements ServiceProvider
13
{
14
    public function getServices()
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