Completed
Push — develop ( 792e1e...b16138 )
by Peter
01:45
created

Local   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 91
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A toArray() 0 65 3
1
<?php
2
3
namespace WebinoDev\Config\App;
4
5
use BjyProfiler\Db\Adapter\ProfilingAdapter;
6
use BjyProfiler\Db\Profiler\Profiler;
7
use ZendDeveloperTools\Collector\DbCollector;
8
9
/**
10
 * Application local config
11
 */
12
class Local
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $dir;
18
19
    /**
20
     * @var array
21
     */
22
    protected $override = [];
23
24
    /**
25
     * @param string $dir
26
     * @param array $override
27
     */
28
    public function __construct($dir, array $override = [])
29
    {
30
        $this->dir      = $dir;
31
        $this->override = $override;
32
    }
33
34
    /**
35
     * @return array
36
     */
37
    public function toArray()
38
    {
39
        return array_replace_recursive(
40
            [
41
                'di' => [
42
                    'instance' => [
43
                        'alias' => [
44
                            'dbProfiler' => Profiler::class,
45
                        ],
46
                        Profiler::class => [
47
                            'parameters' => [
48
                                'enabled' => 'true',
49
                            ],
50
                        ],
51
                        DbCollector::class => [
52
                            'parameters' => [
53
                                'profiler' => 'dbProfiler',
54
                            ],
55
                        ],
56
                    ],
57
                ],
58
                'service_manager' => [
59
                    'factories' => [
60
                        'defaultDb' => function ($services) {
61
                            $config = $services->get('Config')['db'];
62
                            if (empty($config)) {
63
                                return null;
64
                            }
65
66
                            $profiler = $services->get('dbProfiler');
67
                            if (class_exists(ProfilingAdapter::class)) {
68
                                $adapter = new ProfilingAdapter($config);
69
                                $adapter->setProfiler($profiler);
70
                                $adapter->injectProfilingStatementPrototype();
71
                            } else {
72
                                $adapter = new Adapter($config);
73
                            }
74
                            return $adapter;
75
                        },
76
                    ],
77
                ],
78
                'view_manager' => [
79
                    'display_not_found_reason' => true,
80
                    'display_exceptions'       => true,
81
                ],
82
                'asset_manager' => [
83
                    'caching' => [
84
                        'default' => [
85
                            'cache' => 'FilePath',
86
                            'options' => [
87
                                'dir' => $this->dir . '/../../public',
88
                            ],
89
                        ],
90
                        'favicon.ico' => [
91
                            'cache' => 'Filesystem',
92
                            'options' => [
93
                                'dir' => 'tmp/cache/common/assets',
94
                            ],
95
                        ],
96
                    ],
97
                ],
98
            ],
99
            $this->override
100
        );
101
    }
102
}
103