Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
Voice | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
getOptions | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | /** |
6 | * Setting: Voice |
7 | * |
8 | * @package Beyondwords\Wordpress |
9 | * @author Stuart McAlpine <stu@beyondwords.io> |
10 | * @since 5.0.0 |
11 | */ |
12 | |
13 | namespace Beyondwords\Wordpress\Component\Settings\Fields\Voice; |
14 | |
15 | use Beyondwords\Wordpress\Core\ApiClient; |
16 | |
17 | /** |
18 | * Voice |
19 | * |
20 | * @since 5.0.0 |
21 | */ |
22 | abstract class Voice |
23 | { |
24 | /** |
25 | * Get all options for the current component. |
26 | * |
27 | * @since 5.0.0 |
28 | * @since 5.4.0 |
29 | * |
30 | * @return string[] Associative array of options. |
31 | **/ |
32 | public function getOptions() |
33 | { |
34 | $languageCode = get_option('beyondwords_project_language_code'); |
35 | if ($languageCode) { |
36 | $voices = ApiClient::getVoices($languageCode); |
37 | } |
38 | |
39 | if (! $voices) { |
40 | return []; |
41 | } |
42 | |
43 | $options = array_map(function ($voice) { |
44 | return [ |
45 | 'value' => $voice['id'], |
46 | 'label' => $voice['name'], |
47 | ]; |
48 | }, $voices); |
49 | |
50 | return $options; |
51 | } |
52 | } |