Passed
Push — master ( d8e403...d1c323 )
by Paul
05:05
created

Rating::required()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 10
ccs 0
cts 10
cp 0
crap 6
rs 9.4285
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
use GeminiLabs\SiteReviews\Modules\Rating as RatingModule;
7
8
class Rating extends Field
9
{
10
	/**
11
	 * @return string|void
12
	 */
13
	public function build()
14
	{
15
		$this->mergeFieldArgs();
16
		$this->builder->tag = 'select';
17
		return $this->builder->buildFormSelect();
18
	}
19
20
	/**
21
	 * @return array
22
	 */
23
	public static function required()
24
	{
25
		$options = ['' => __( 'Select a Rating', 'site-reviews' )];
26
		foreach( range( RatingModule::MAX_RATING, 1 ) as $rating ) {
27
			$options[$rating] = sprintf( _n( '%s Star', '%s Stars', $rating, 'site-reviews' ), $rating );
28
		}
29
		return [
30
			'class' => 'glsr-star-rating',
31
			'options' => $options,
32
			'type' => 'select',
33
		];
34
	}
35
}
36