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

Container::add_service()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
}