Passed
Push — master ( e29497...7ab2d6 )
by Paul
04:36
created

Languages::required()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules\Html\Fields;
4
5
use GeminiLabs\SiteReviews\Modules\Html\Fields\Field;
6
7
class Languages extends Field
8
{
9
	/**
10
	 * @return string|void
11
	 */
12
	public function build()
13
	{
14
		$this->builder->tag = 'select';
15
		$this->mergeFieldArgs();
16
		return $this->builder->buildFormSelect();
17
	}
18
19
	/**
20
	 * @return array
21
	 */
22
	public static function required()
23
	{
24
		return [
25
			'options' => static::options(),
26
			'type' => 'select',
27
		];
28
	}
29
30
	/**
31
	 * @return array
32
	 */
33
	protected static function options()
34
	{
35
		require_once( ABSPATH.'wp-admin/includes/translation-install.php' );
36
		$locales = wp_get_available_translations();
37
		array_walk( $locales, function( &$value ) {
38
			$value = $value['native_name'];
39
		});
40
		$locales['en_US'] = 'English (United States)';
41
		ksort( $locales );
42
		return $locales;
43
	}
44
}
45