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

TestServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 29
rs 10
c 2
b 0
f 0
wmc 3
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createServiceB() 0 7 1
A getFactories() 0 13 1
A getExtensions() 0 4 1
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