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

Rating   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A required() 0 10 2
A build() 0 5 1
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