Completed
Push — try/capabilities ( 672273...ec87c0 )
by
unknown
15:57 queued 09:35
created

Capabilities   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A register() 0 4 1
1
<?php
2
/**
3
 * Top level object for registering and fetching named capabilities, e.g. 'jetpack.backups.restore'
4
 *
5
 * @package automattic/jetpack-capabilities
6
 */
7
8
namespace Automattic\Jetpack;
9
10
use \Automattic\Jetpack\Capabilities\Capability;
11
12
// phpcs:ignore Squiz.Commenting.ClassComment.Missing
13
class Capabilities {
14
	/**
15
	 * The list of registered capabilities
16
	 *
17
	 * @var array capabilities
18
	 */
19
	private static $capabilities = [];
20
21
	// phpcs:ignore Squiz.Commenting.FunctionComment.Missing
22
	public static function get( $name ) {
23
		return self::$capabilities[ $name ];
24
	}
25
26
	// phpcs:ignore Squiz.Commenting.FunctionComment.Missing
27
	public static function register( $capability ) {
28
		// TODO check for clashes?
29
		self::$capabilities[ $capability->name ] = $capability;
30
	}
31
}
32