V4ModuleDefinition   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 75
c 2
b 0
f 0
dl 0
loc 101
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 11 4
1
<?php
2
/**
3
 * @copyright 2013 - 2019, Stephan Gambke
4
 * @license   GPL-3.0-or-later
5
 *
6
 * This file is part of the MediaWiki extension Bootstrap.
7
 * The Bootstrap extension is free software: you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * The Bootstrap extension is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @file
21
 * @ingroup   Bootstrap
22
 */
23
24
namespace Bootstrap\Definition;
25
26
use InvalidArgumentException;
27
28
/**
29
 * Class describing the Bootstrap 4 module definitions
30
 *
31
 * @since 4.0
32
 * @ingroup   Bootstrap
33
 */
34
class V4ModuleDefinition implements ModuleDefinition {
35
36
	private static $moduleDescriptions = [
37
		'functions'         => [ 'styles' => [ 'functions' => [ 'position' => 'functions' ] ] ],
38
		'variables'         => [ 'styles' =>
39
			[ 'variables' => [ 'position' => 'variables' ] ], 'dependencies' => 'functions' ],
40
		'mixins'            => [ 'styles' => 'mixins' ],
41
		'root'              => [ 'styles' => 'root' ],
42
		'reboot'            => [ 'styles' => 'reboot' ],
43
		'type'              => [ 'styles' => 'type' ],
44
		'images'            => [ 'styles' => 'images' ],
45
		'code'              => [ 'styles' => 'code' ],
46
		'grid'              => [ 'styles' => 'grid' ],
47
		'tables'            => [ 'styles' => 'tables' ],
48
		'forms'             => [ 'styles' => 'forms' ],
49
		'buttons'           => [ 'styles' => 'buttons' ],
50
		'transitions'       => [ 'styles' => 'transitions' ],
51
		'dropdown'          => [ 'styles' =>
52
			'dropdown', 'scripts' => 'dropdown.js', 'dependencies' => [ 'popper', 'js-util' ] ],
53
		'button-group'      => [ 'styles' => 'button-group', 'dependencies' => [ 'buttons' ] ],
54
		'input-group'       => [ 'styles' => 'input-group', 'dependencies' => [ 'forms' ] ],
55
		'custom-forms'      => [ 'styles' => 'custom-forms' ],
56
		'nav'               => [ 'styles' => 'nav' ],
57
		'navbar'            => [ 'styles' => 'navbar' ],
58
		'card'              => [ 'styles' => 'card' ],
59
		'breadcrumb'        => [ 'styles' => 'breadcrumb' ],
60
		'pagination'        => [ 'styles' => 'pagination' ],
61
		'badge'             => [ 'styles' => 'badge' ],
62
		'jumbotron'         => [ 'styles' => 'jumbotron' ],
63
		'alert'             => [ 'styles' => 'alert' ],
64
		'progress'          => [ 'styles' => 'progress' ],
65
		'media'             => [ 'styles' => 'media' ],
66
		'list-group'        => [ 'styles' => 'list-group' ],
67
		'close'             => [ 'styles' => 'close' ],
68
		'toasts'            => [ 'styles' =>
69
			'toasts', 'scripts' => 'toast.js', 'dependencies' => 'js-util' ],
70
		'modal'             => [ 'styles' => 'modal', 'scripts' => 'modal.js' ],
71
		'tooltip'           => [ 'styles' => 'tooltip', 'scripts' => 'tooltip.js', 'dependencies' => [ 'popper', 'js-util' ] ],
72
		'popover'           => [ 'styles' =>
73
			'popover', 'scripts' => 'popover.js', 'dependencies' => [ 'popper', 'tooltip', 'js-util' ] ],
74
		'carousel'          => [ 'styles' =>
75
			'carousel', 'scripts' => 'carousel.js', 'dependencies' => 'js-util' ],
76
		'spinners'          => [ 'styles' => 'spinners' ],
77
		'utilities'         => [ 'styles' => 'utilities' ],
78
		'print'             => [ 'styles' => 'print' ],
79
		'active-buttons'    => [ 'scripts' => 'button.js', 'dependencies' => [ 'buttons' ] ],
80
		'dismissable-alert' => [ 'scripts' => 'alert.js', 'dependencies' => [ 'alert', 'js-util' ] ],
81
		'collapse'          => [ 'scripts' => 'collapse.js' ],
82
		'scrollspy'         => [ 'scripts' => 'scrollspy.js', 'dependencies' => [ 'popper', 'js-util' ] ],
83
		'tab'               => [ 'scripts' => 'tab.js', 'dependencies' => [ 'list-group' ] ],
84
		'js-util'           => [ 'scripts' => 'util.js' ],
85
		'popper'            => [ 'scripts' => 'popper.js' ],
86
87
		'bs-core'   => [ 'dependencies' => [ 'variables', 'mixins' ] ],
88
		'bs-reboot' => [ 'dependencies' => [ 'bs-core', 'reboot' ] ],
89
		'bs-grid'   => [ 'styles' => 'bootstrap-grid' ],
90
91
		'bs-basic'  => [ 'dependencies' => [
92
			'bs-core', 'root', 'reboot', 'type', 'images', 'code', 'grid',
93
			'tables', 'transitions', 'utilities', 'print'
94
		] ],
95
96
		'bs-all'    => [ 'dependencies' => [
97
			'bs-core', 'root', 'reboot', 'type', 'images', 'code', 'grid',
98
			'tables', 'forms', 'buttons', 'transitions', 'dropdown',
99
			'button-group', 'input-group', 'custom-forms', 'nav', 'navbar',
100
			'card', 'breadcrumb', 'pagination', 'badge', 'jumbotron', 'alert',
101
			'progress', 'media', 'list-group', 'close', 'toasts', 'modal', 'tooltip',
102
			'popover', 'carousel', 'spinners', 'utilities', 'print', 'active-buttons',
103
			'dismissable-alert', 'collapse', 'scrollspy', 'tab', 'js-util',
104
		] ],
105
106
		// TODO: Add each SCSS util separately?
107
		// TODO: Add each SCSS mixin module separately?
108
109
	];
110
111
	private static $coreModules = [ 'bs-core' ];
112
	private static $optionalModules = [ 'bs-all' ];
113
114
	/**
115
	 * @see ModuleDefinition::get
116
	 *
117
	 * @since  1.0
118
	 *
119
	 * @param string $key
120
	 *
121
	 * @return array
122
	 * @throws InvalidArgumentException
123
	 */
124
	public function get( $key ) {
125
		switch ( $key ) {
126
			case 'core':
127
				return self::$coreModules;
128
			case 'optional':
129
				return self::$optionalModules;
130
			case 'descriptions':
131
				return self::$moduleDescriptions;
132
		}
133
134
		throw new InvalidArgumentException( 'Expected a valid key' );
135
	}
136
137
}
138