Completed
Branch master (479eaa)
by Atanas
02:08
created

ApplicationServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 20
rs 10
c 2
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 6 1
A bootstrap() 0 3 1
1
<?php
2
/**
3
 * @package   WPEmerge
4
 * @author    Atanas Angelov <[email protected]>
5
 * @copyright 2018 Atanas Angelov
6
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7
 * @link      https://wpemerge.com/
8
 */
9
10
namespace WPEmerge\Application;
11
12
use WPEmerge\Helpers\MixedType;
13
use WPEmerge\ServiceProviders\ExtendsConfigTrait;
14
use WPEmerge\ServiceProviders\ServiceProviderInterface;
15
16
/**
17
 * Provide application dependencies.
18
 *
19
 * @codeCoverageIgnore
20
 */
21
class ApplicationServiceProvider implements ServiceProviderInterface {
22
	use ExtendsConfigTrait;
23
24
	/**
25
	 * {@inheritDoc}
26
	 */
27
	public function register( $container ) {
28
		$this->extendConfig( $container, 'providers', [] );
29
30
		$upload_dir = wp_upload_dir();
31
		$cache_dir = MixedType::addTrailingSlash( $upload_dir['basedir'] ) . 'wpemerge' . DIRECTORY_SEPARATOR . 'cache';
32
		$this->extendConfig( $container, 'cache', $cache_dir );
33
	}
34
35
	/**
36
	 * {@inheritDoc}
37
	 */
38
	public function bootstrap( $container ) {
39
		$cache_dir = $container[ WPEMERGE_CONFIG_KEY ]['cache'];
40
		wp_mkdir_p( $cache_dir );
41
	}
42
}
43