Completed
Pull Request — staging (#840)
by
unknown
15:43
created

Container   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 2
A get_services() 0 3 1
A add_service() 0 3 1
A remove_service() 0 3 1
1
<?php
2
/**
3
 * YIKES Inc. Easy Forms.
4
 *
5
 * @package YIKES\EasyForms
6
 * @author  Freddie Mixell
7
 * @license GPL2
8
 */
9
10
namespace YIKES\EasyForms;
11
12
/**
13
 * Class Container
14
 *
15
 * @since   %VERSION%
16
 * @package YIKES\EasyForms
17
 */
18
final class Container {
19
20
	/**
21
	 * The registered services for the container.
22
	 *
23
	 * @since %VERSION%
24
	 * @var array
25
	 */
26
	protected $services = [];
27
28
	/**
29
	 * Container constructor.
30
	 *
31
	 * @param array $services Services to register with the container.
32
	 */
33
	public function __construct( array $services = [] ) {
34
		$this->services = $services ?: [];
35
	}
36
37
	/**
38
	 * Get the services from the container.
39
	 *
40
	 * @since %VERSION%
41
	 * @return array
42
	 */
43
	public function get_services() {
44
		return $this->services;
45
	}
46
47
	/**
48
	 * Add a service to the container.
49
	 *
50
	 * @since %VERSION%
51
	 *
52
	 * @param string $service Service class name.
53
	 */
54
	public function add_service( $service ) {
55
		$this->services[ $service ] = true;
56
	}
57
58
	/**
59
	 * Remove a service from the container.
60
	 *
61
	 * @since %VERSION%
62
	 *
63
	 * @param string $service Service class name.
64
	 */
65
	public function remove_service( $service ) {
66
		unset( $this->services[ $service ] );
67
	}
68
}